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

Configure Feed

Select the types of activity you want to include in your feed.

Combine useDialogFocus isActive state

+3 -2
+3 -2
src/useDialogFocus.ts
··· 23 23 const ownerRef = options && options.ownerRef; 24 24 const disabled = !!(options && options.disabled); 25 25 const hasPriority = usePriority(ref, disabled); 26 + const isActive = !disabled && !!hasPriority; 26 27 27 28 useLayoutEffect(() => { 28 - if (!ref.current || disabled || !hasPriority) return; 29 + if (!ref.current || !isActive) return; 29 30 30 31 let selection = snapshotSelection(ownerRef && ownerRef.current); 31 32 let willReceiveFocus = false; ··· 174 175 document.body.removeEventListener('focusin', onFocus); 175 176 document.removeEventListener('keydown', onKey); 176 177 }; 177 - }, [ref, hasPriority, disabled]); 178 + }, [ref, isActive]); 178 179 }