carbon-design-system / carbon-components-svelte

Svelte implementation of the Carbon Design System
https://svelte.carbondesignsystem.com
Apache License 2.0
2.68k stars 261 forks source link

fix(header-search): blur input when `active` is false #1857

Closed metonym closed 10 months ago

metonym commented 10 months ago

Fast-follow to #1855

1855 correctly blurred the input on "Escape." However, if programmatically de-activating the search bar (e.g., setting active to false or selecting an option), the input remains focused.

For example, the following bug occurs:

  1. Activate search bar.
  2. Select an option in the menu.
  3. The input is "visually" collapsed but the element retains focus.

A more holistic approach would be to use a reactive statement and blur the input when active becomes false. This is similar to how the input is focused when active is true.