Skip to content

fix(Autocomplete): keep typed text instead of restoring suggestion on blur - #7918

Merged
jonrohan merged 1 commit into
mainfrom
fix-autocomplete-blur-suggestion
Jun 8, 2026
Merged

fix(Autocomplete): keep typed text instead of restoring suggestion on blur#7918
jonrohan merged 1 commit into
mainfrom
fix-autocomplete-blur-suggestion

Conversation

@jonrohan

Copy link
Copy Markdown
Member

Closes#4275

Fixes an inconsistency in the Autocomplete component. 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

  • Autocomplete now keeps the typed text instead of restoring the full inline suggestion when the input loses focus.

Rollout strategy

  • Patch release

Testing & Reviewing

Open the Autocomplete default 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

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Storybook)
  • Changes are SSR compatible
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

CopilotAI review requested due to automatic review settings June 2, 2026 21:38
@jonrohan
jonrohan requested a review from a team as a code ownerJune 2, 2026 21:38
@jonrohan
jonrohan requested a review from TylerJDevJune 2, 2026 21:38
@changeset-bot

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f2aaf29

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
@primer/reactPatch

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

@github-actionsgithub-actionsBot added the staff Author is a staff member label Jun 2, 2026
@jonrohanjonrohan added the Canary Release Apply this label when you want CI to create a canary release of the current PR label Jun 2, 2026
@github-actionsgithub-actionsBot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jun 2, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

To publish a canary release for integration testing, apply the Canary Release label to this PR.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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
FileDescription
packages/react/src/Autocomplete/AutocompleteInput.tsxEnsures blur keeps the user-typed text and guards inline-suggestion application to focused inputs only.
packages/react/src/Autocomplete/Autocomplete.test.tsxAdds a regression test that blurring the input retains typed text instead of the inline suggestion.
.changeset/autocomplete-blur-suggestion.mdPatch changeset describing the Autocomplete blur behavior fix for release notes.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@primer-integration

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Passed CI  Passed
Passed VRT  Passed
Passed Projects  Passed

All checks passed!

@jonrohanjonrohan added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Jun 2, 2026
@jonrohan
jonrohan added this pull request to the merge queueJun 8, 2026
Merged via the queue into main with commit 95986ceJun 8, 2026
70 of 71 checks passed
@jonrohan
jonrohan deleted the fix-autocomplete-blur-suggestion branch June 8, 2026 13:40
@primerprimerBot mentioned this pull request Jun 8, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Canary ReleaseApply this label when you want CI to create a canary release of the current PRintegration-tests: passingChanges in this PR do NOT cause breaking changes in gh/ghstaffAuthor is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autocomplete behavior discrepancy between Esc and clickoutside

3 participants

@jonrohan@TylerJDev