Skip to content

Fix AutoCompleteInput value does not get updated when re-selecting the same option#11254

Open
smeng9 wants to merge 3 commits into
marmelab:masterfrom
smeng9:fix/autocomplete-input-reselection-update
Open

Fix AutoCompleteInput value does not get updated when re-selecting the same option#11254
smeng9 wants to merge 3 commits into
marmelab:masterfrom
smeng9:fix/autocomplete-input-reselection-update

Conversation

@smeng9
Copy link
Copy Markdown
Contributor

@smeng9 smeng9 commented May 8, 2026

Problem

See original problem in #11209
Closes #11209

Solution

Add additional check for handleInputChange with the condition reason='reset'

How To Test

  1. Open the FilterSelectedOptionsFalse story in Storybook.
  2. The input starts with a pre-selected author (e.g. "Leo Tolstoy").
  3. Click into the input and delete one character (e.g. → "Leo Tolsto"). The dropdown should remain open showing "Leo
    Tolstoy".
  4. Click "Leo Tolstoy" in the dropdown.
  5. Expected: the input immediately shows "Leo Tolstoy" and focus stays in the field.
  6. Before this fix: the input stayed at "Leo Tolsto" until blur.

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • The PR includes unit tests (if not possible, describe why)
  • The PR includes one or several stories (if not possible, describe why)
  • The documentation is up to date

…option with filterSelectedOptions=false

When filterSelectedOptions is false, selecting an already-selected option
after partially deleting the input text left the input showing the partial
text until blur. MUI fires onInputChange with reason='reset' in this case
but the handler only updated filterValue on user-typing events or when the
new value differed from the selection. Added handling for reason='reset'
with event !== null (to skip MUI's programmatic useEffect resets) and
doesQueryMatchSelection (to skip create-option clicks).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@smeng9
Copy link
Copy Markdown
Contributor Author

smeng9 commented May 8, 2026

Before and after video comparisons

Untitled.mov

Copy link
Copy Markdown
Contributor

@jonathanarnault jonathanarnault left a comment

Choose a reason for hiding this comment

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

Hi @smeng9, thank you for your contribution to React Admin!

This fix looks good to me but I cannot test it right away as there are no story that highlights this fix. Can you add one ?

Also, it would be great if you used the PR template in the repository, this would help us search changes when needed.

Shaoyu Meng and others added 2 commits May 18, 2026 12:11
…dOptions=false

Adds a Storybook story to demonstrate and visually verify the fix for
the case where re-selecting the same option after partial text deletion
should immediately restore the full label without requiring a blur event.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@smeng9
Copy link
Copy Markdown
Contributor Author

smeng9 commented May 18, 2026

Hi @jonathanarnault,

I have updated the merge request to include stories and use the merge request template

@smeng9 smeng9 requested a review from jonathanarnault May 18, 2026 20:16
Copy link
Copy Markdown
Contributor

@jonathanarnault jonathanarnault left a comment

Choose a reason for hiding this comment

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

LGTM, thank your for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AutocompleteInput: inconsistent input update behavior with filterSelectedOptions={false} compared to MUI

2 participants