1313import { AriaLabelingProps , BaseEvent , DOMProps , FocusableElement , FocusEvents , KeyboardEvents , Node , RefObject , ValueBase } from '@react-types/shared' ;
1414import { AriaTextFieldProps } from '@react-aria/textfield' ;
1515import { AutocompleteProps , AutocompleteState } from '@react-stately/autocomplete' ;
16- import { CLEAR_FOCUS_EVENT , FOCUS_EVENT , getActiveElement , getOwnerDocument , isAndroid , isCtrlKeyPressed , isIOS , mergeProps , mergeRefs , useEffectEvent , useEvent , useId , useLabels , useObjectRef } from '@react-aria/utils' ;
16+ import { CLEAR_FOCUS_EVENT , FOCUS_EVENT , getActiveElement , getOwnerDocument , isAndroid , isCtrlKeyPressed , isIOS , mergeProps , mergeRefs , useEvent , useId , useLabels , useObjectRef , useStableCallback } from '@react-aria/utils' ;
1717import { dispatchVirtualBlur , dispatchVirtualFocus , getVirtuallyFocusedElement , moveVirtualFocus } from '@react-aria/focus' ;
1818import { getInteractionModality } from '@react-aria/interactions' ;
1919// @ts -ignore
@@ -106,7 +106,7 @@ export function useAutocomplete<T>(props: AriaAutocompleteOptions<T>, state: Aut
106106 return ( ) => clearTimeout ( timeout . current ) ;
107107 } , [ ] ) ;
108108
109- let updateActiveDescendant = useEffectEvent ( ( e : Event ) => {
109+ let updateActiveDescendant = useStableCallback ( ( e : Event ) => {
110110 // Ensure input is focused if the user clicks on the collection directly.
111111 if ( ! e . isTrusted && shouldUseVirtualFocus && inputRef . current && getActiveElement ( getOwnerDocument ( inputRef . current ) ) !== inputRef . current ) {
112112 inputRef . current . focus ( ) ;
@@ -165,7 +165,7 @@ export function useAutocomplete<T>(props: AriaAutocompleteOptions<T>, state: Aut
165165 // Make sure to memo so that React doesn't keep registering a new event listeners on every rerender of the wrapped collection
166166 let mergedCollectionRef = useObjectRef ( useMemo ( ( ) => mergeRefs ( collectionRef , callbackRef ) , [ collectionRef , callbackRef ] ) ) ;
167167
168- let focusFirstItem = useEffectEvent ( ( ) => {
168+ let focusFirstItem = useStableCallback ( ( ) => {
169169 delayNextActiveDescendant . current = true ;
170170 collectionRef . current ?. dispatchEvent (
171171 new CustomEvent ( FOCUS_EVENT , {
@@ -178,7 +178,7 @@ export function useAutocomplete<T>(props: AriaAutocompleteOptions<T>, state: Aut
178178 ) ;
179179 } ) ;
180180
181- let clearVirtualFocus = useEffectEvent ( ( clearFocusKey ?: boolean ) => {
181+ let clearVirtualFocus = useStableCallback ( ( clearFocusKey ?: boolean ) => {
182182 moveVirtualFocus ( getActiveElement ( ) ) ;
183183 queuedActiveDescendant . current = null ;
184184 state . setFocusedNodeId ( null ) ;
@@ -321,7 +321,7 @@ export function useAutocomplete<T>(props: AriaAutocompleteOptions<T>, state: Aut
321321 }
322322 } ;
323323
324- let onKeyUpCapture = useEffectEvent ( ( e ) => {
324+ let onKeyUpCapture = useStableCallback ( ( e ) => {
325325 // Dispatch simulated key up events for things like triggering links in listbox
326326 // Make sure to stop the propagation of the input keyup event so that the simulated keyup/down pair
327327 // is detected by usePress instead of the original keyup originating from the input
0 commit comments