Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
React.useEffect(() => {
const initialFocusRef = options.focusRef;
const shouldFocus = options.visible && options.autoFocus;
if (shouldFocus) {
if (initialFocusRef && initialFocusRef.current) {
ensureFocus(initialFocusRef.current);
} else {
if (ref.current) {
const firstTabbable = getFirstTabbableIn(ref.current, true);
if (firstTabbable) {
ensureFocus(firstTabbable);
} else {
ensureFocus(ref.current);
}
}
}
}
}, [options.visible, options.autoFocus, ref, options.focusRef]);
}