Mirror: React hooks for accessible, common web interactions. UI super powers without the UI.

Update contains usage in useModalFocus

Changed files
+4 -6
src
+1 -1
src/useModalFocus.ts
···
let selection: RestoreSelection | null = null;
if (
!document.activeElement ||
-
!ref.current.contains(document.activeElement)
+
!contains(ref.current, document.activeElement)
) {
const newTarget = getAutofocusTarget(ref.current);
selection = snapshotSelection(ref.current);
+3 -5
src/usePriority.ts
···
ref: Ref<T>,
disabled?: boolean
): boolean {
-
function computeHasPriority(): boolean {
+
const isDisabled = !!disabled;
+
const [hasPriority, setHasPriority] = useState(() => {
if (!ref.current) return false;
const tempStack = priorityStack.concat(ref.current).sort(sortByHierarchy);
return tempStack[0] === ref.current;
-
}
-
-
const isDisabled = !!disabled;
-
const [hasPriority, setHasPriority] = useState(computeHasPriority);
+
});
useLayoutEffect(() => {
if (!ref.current || isDisabled) return;