Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display glitch in Search component #1981

Closed
jmeurice opened this issue Jul 11, 2024 · 1 comment · Fixed by #1987
Closed

Display glitch in Search component #1981

jmeurice opened this issue Jul 11, 2024 · 1 comment · Fixed by #1987
Labels
bug Something isn't working

Comments

@jmeurice
Copy link
Contributor

There is an edge case in the Search component:

  • Enter some whitespace in the search with expandable=true
  • Blur the Search (focus something else or using JS)
  • The Search collapses but the clear button stays visible.

Screenshot:

image

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

class:bx--search-close--hidden="{value === ''}"

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

on:blur="{() => {
if (expanded && value.trim().length === 0) {
expanded = false;
}
}}"

Possible fixes:

  • Do not collapse when the value is whitespace only.
  • On blur, clear the value if it's whitespace only. However this mutates the user input, which could be whitespace intentionally.
  • Hide the clear button when expanded is false. Again this might hide the search when the contained value is whitespace.

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
Copy link
Collaborator

metonym commented Jul 23, 2024

Yes – PRs always welcome.

@metonym metonym added the bug Something isn't working label Jul 23, 2024
jmeurice pushed a commit to jmeurice/carbon-components-svelte that referenced this issue Jul 29, 2024
@metonym metonym closed this as completed in 216d5a3 Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants