Skip to content

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

Open
jonrohan wants to merge 1 commit into
mainfrom
fix-autocomplete-blur-suggestion
Open

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

Conversation

@jonrohan
Copy link
Copy Markdown
Member

@jonrohan jonrohan commented Jun 2, 2026

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

Copilot AI review requested due to automatic review settings June 2, 2026 21:38
@jonrohan jonrohan requested a review from a team as a code owner June 2, 2026 21:38
@jonrohan jonrohan requested a review from TylerJDev June 2, 2026 21:38
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 2, 2026

🦋 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
Name Type
@primer/react Patch

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-actions github-actions Bot added the staff Author is a staff member label Jun 2, 2026
@jonrohan jonrohan 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-actions github-actions Bot 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

github-actions Bot commented Jun 2, 2026

⚠️ 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
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

@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!

@jonrohan jonrohan 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Canary Release Apply this label when you want CI to create a canary release of the current PR integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autocomplete behavior discrepancy between Esc and clickoutside

2 participants