fix(Autocomplete): keep typed text instead of restoring suggestion on blur#7918
fix(Autocomplete): keep typed text instead of restoring suggestion on blur#7918jonrohan wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: f2aaf29 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
There was a problem hiding this comment.
Pull request overview
This pull request fixes a user-facing inconsistency in Autocomplete.Input where blurring the input could restore the full inline suggestion (e.g. jumping back to “alligator”) instead of keeping the text the user actually typed. The change aligns blur behavior with the existing Escape-key behavior and adds a regression test plus a patch changeset.
Changes:
- Prevent inline suggestions from being re-applied after the input loses focus, and reset the DOM value to the typed text on blur.
- Add a unit test ensuring blur does not restore the full inline suggestion.
- Add a patch changeset for
@primer/react.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/Autocomplete/AutocompleteInput.tsx | Ensures blur keeps the user-typed text and guards inline-suggestion application to focused inputs only. |
| packages/react/src/Autocomplete/Autocomplete.test.tsx | Adds a regression test that blurring the input retains typed text instead of the inline suggestion. |
| .changeset/autocomplete-blur-suggestion.md | Patch changeset describing the Autocomplete blur behavior fix for release notes. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 0
|
Integration test results from github/github-ui PR:
All checks passed! |
Closes #4275
Fixes an inconsistency in the
Autocompletecomponent. Previously, pressing Escape cleared the input, but clicking outside (blurring) silently restored the full inline autocomplete suggestion. For example, after selecting "alligator" and deleting characters to get "alligat", clicking away would jump the value back to "alligator".Now blurring the input keeps the text the user actually typed, matching the Escape behavior.
Changelog
Changed
Autocompletenow keeps the typed text instead of restoring the full inline suggestion when the input loses focus.Rollout strategy
Testing & Reviewing
Open the
Autocompletedefault story, type to get an inline suggestion, delete a few characters off the end, then click outside the input. The input retains the typed text rather than restoring the full suggestion. A unit test (does not restore the autocomplete suggestion when the input is blurred) covers this behavior.Merge checklist