Skip to content

Commit

Permalink
fix(Select): refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
iapolya committed Feb 11, 2025
1 parent 3e8f9ca commit 00b2481
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/hooks/useFocusWithin/useFocusWithin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as React from 'react';

import {useMobile} from '../../components/mobile';

import {SyntheticFocusEvent} from './SyntheticFocusEvent';
import {useSyntheticBlurEvent} from './useSyntheticBlurEvent';

Expand Down Expand Up @@ -145,8 +143,6 @@ function useFocusEvents<T extends Element = Element>({
const capturedRef = React.useRef(false);
const targetRef = React.useRef<EventTarget | null>(null);

const mobile = useMobile();

React.useEffect(() => {
if (isDisabled) {
return undefined;
Expand Down Expand Up @@ -189,15 +185,15 @@ function useFocusEvents<T extends Element = Element>({
(event: React.FocusEvent<T>) => {
if (
document.activeElement !== event.target &&
((!mobile && event.relatedTarget === null) ||
(event.relatedTarget === null ||
event.relatedTarget === document.body ||
event.relatedTarget === (document as EventTarget))
) {
onBlur(event);
targetRef.current = null;
}
},
[mobile, onBlur],
[onBlur],
);

const onSyntheticFocus = useSyntheticBlurEvent(onBlur);
Expand Down

0 comments on commit 00b2481

Please sign in to comment.