File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
packages/react/src/floating-ui-react/hooks Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 11import * as React from 'react' ;
22import { useStableCallback } from '@base-ui-components/utils/useStableCallback' ;
33import { useTimeout } from '@base-ui-components/utils/useTimeout' ;
4- import { stopEvent } from '../utils' ;
4+ import { contains , stopEvent } from '../utils' ;
55import type { ElementProps , FloatingContext , FloatingRootContext } from '../types' ;
66import { 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 ( ( ) => {
You can’t perform that action at this time.
0 commit comments