carbon-design-system / carbon-components-svelte

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

Display glitch in Search component #1981

Closed jmeurice closed 1 month ago

jmeurice commented 1 month ago

There is an edge case in the Search component:

Screenshot:

image

This is due to the fact that the visibility of the clear button is decided by value === '':

https://github.com/carbon-design-system/carbon-components-svelte/blob/ba27830b2f6ad1fb2c8cc7dc1a8c833cf9e236d0/src/Search/Search.svelte#L162-L162

However the search is collapsed when the trimmed value is empty:

https://github.com/carbon-design-system/carbon-components-svelte/blob/ba27830b2f6ad1fb2c8cc7dc1a8c833cf9e236d0/src/Search/Search.svelte#L142-L146

Possible fixes:

The first version sounds the most consistent with API to me. Users can choose to clear the value if its empty on blur manually.

I can do a PR if this sounds good.

metonym commented 1 month ago

Yes – PRs always welcome.