From ba17e5960231c179d8241842a487ca3835c7101f Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 29 Oct 2024 07:34:31 +0400 Subject: [PATCH] Components: Fix React Compiler error for 'useAutocomplete' (#66496) Co-authored-by: Mamaduka Co-authored-by: tyxla --- packages/components/src/autocomplete/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/components/src/autocomplete/index.tsx b/packages/components/src/autocomplete/index.tsx index f3278a46015c3c..7a75be8eca5c84 100644 --- a/packages/components/src/autocomplete/index.tsx +++ b/packages/components/src/autocomplete/index.tsx @@ -97,7 +97,7 @@ export function useAutocomplete( { ( ( props: AutocompleterUIProps ) => JSX.Element | null ) | null >( null ); - const backspacing = useRef( false ); + const backspacingRef = useRef( false ); function insertCompletion( replacement: React.ReactNode ) { if ( autocompleter === null ) { @@ -177,7 +177,7 @@ export function useAutocomplete( { } function handleKeyDown( event: KeyboardEvent ) { - backspacing.current = event.key === 'Backspace'; + backspacingRef.current = event.key === 'Backspace'; if ( ! autocompleter ) { return; @@ -323,7 +323,7 @@ export function useAutocomplete( { // Ex: "Some text @marcelo sekkkk" <--- "kkkk" caused a mismatch, but // if the user presses backspace here, it will show the completion popup again. const matchingWhileBackspacing = - backspacing.current && wordsFromTrigger.length <= 3; + backspacingRef.current && wordsFromTrigger.length <= 3; if ( mismatch && ! ( matchingWhileBackspacing || hasOneTriggerWord ) ) { if ( autocompleter ) {