Skip to content

Commit 073d9fa

Browse files
committed
lint
1 parent 84ff090 commit 073d9fa

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/react/src/floating-ui-react/hooks/useTypeahead.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { useStableCallback } from '@base-ui-components/utils/useStableCallback';
33
import { useTimeout } from '@base-ui-components/utils/useTimeout';
4-
import { stopEvent } from '../utils';
4+
import { contains, stopEvent } from '../utils';
55
import type { ElementProps, FloatingContext, FloatingRootContext } from '../types';
66
import { EMPTY_ARRAY } from '../../utils/constants';
77

@@ -196,9 +196,16 @@ export function useTypeahead(
196196
}
197197
});
198198

199+
const onBlur = useStableCallback((event: React.FocusEvent) => {
200+
if (contains(store.select('floatingElement'), event.relatedTarget as Element | null)) {
201+
return;
202+
}
203+
clear();
204+
});
205+
199206
const reference: ElementProps['reference'] = React.useMemo(
200-
() => ({ onKeyDown, onBlur: clear }),
201-
[onKeyDown, clear],
207+
() => ({ onKeyDown, onBlur }),
208+
[onKeyDown, onBlur],
202209
);
203210

204211
const floating: ElementProps['floating'] = React.useMemo(() => {

0 commit comments

Comments
 (0)