Skip to content

Fix enhanced select not resetting when clearing selection - #803

Closed
AdamMagued wants to merge 1 commit into
alphagov:mainfrom
AdamMagued:fix/reset-enhanced-select-on-clear
Closed

AdamMagued wants to merge 1 commit into
alphagov:mainfrom
AdamMagued:fix/reset-enhanced-select-on-clear

Conversation

@AdamMagued

Copy link
Copy Markdown

Fixes #777.

Summary

When using enhanceSelectElement, selecting an option synchronizes the underlying <select> element. However, if the user cleared the autocomplete input, the underlying <select> retained the previously selected option.

This change updates the default onConfirm handler to reset the <select> when the query is cleared or does not match any option:

  • If a placeholder option exists (empty value), it is selected.
  • Otherwise, selectedIndex is reset to -1.

Testing

  • npm run standard
  • npm run build
  • Added functional test in test/functional/wrapper.js

@netlify

netlify Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for accessible-autocomplete ready!

Name Link
🔨 Latest commit 319f75b
🔍 Latest deploy log https://app.netlify.com/projects/accessible-autocomplete/deploys/6abb40475714820008492896
😎 Deploy Preview https://deploy-preview-803--accessible-autocomplete.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@AdamMagued

Copy link
Copy Markdown
Author

closing in favor of #804 where i included the full functional test suite and regenerated dist files. sorry for the duplicate PR!

@AdamMagued AdamMagued closed this Sep 30, 2026
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.

Enhanced select does not get reset when removing selected entry

1 participant