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

Combine useDialogFocus isActive state

Changed files
+3 -2
src
+3 -2
src/useDialogFocus.ts
···
const ownerRef = options && options.ownerRef;
const disabled = !!(options && options.disabled);
const hasPriority = usePriority(ref, disabled);
+
const isActive = !disabled && !!hasPriority;
useLayoutEffect(() => {
-
if (!ref.current || disabled || !hasPriority) return;
+
if (!ref.current || !isActive) return;
let selection = snapshotSelection(ownerRef && ownerRef.current);
let willReceiveFocus = false;
···
document.body.removeEventListener('focusin', onFocus);
document.removeEventListener('keydown', onKey);
};
-
}, [ref, hasPriority, disabled]);
+
}, [ref, isActive]);
}