Skip to content

Commit

Permalink
Components: Fix React Compiler error for 'useAutocomplete' (#66496)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
  • Loading branch information
3 people authored Oct 29, 2024
1 parent ffba007 commit ba17e59
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/components/src/autocomplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -177,7 +177,7 @@ export function useAutocomplete( {
}

function handleKeyDown( event: KeyboardEvent ) {
backspacing.current = event.key === 'Backspace';
backspacingRef.current = event.key === 'Backspace';

if ( ! autocompleter ) {
return;
Expand Down Expand Up @@ -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 ) {
Expand Down

1 comment on commit ba17e59

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in ba17e59.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11566816051
📝 Reported issues:

Please sign in to comment.