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

fix(filter-clear): disable clear button when value is empty array #2067

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

Sophmrs
Copy link
Contributor

@Sophmrs Sophmrs commented Jan 28, 2025

Summary

Solves this issue: #2064

Now multi select filter's clear button renders as disabled correctly when the value is an empty array, not only with empty strings (or other falsy values). The behaviour is now the same for single item (radio) or multiple item (checkbox) filters.

Examples

This behavior can be observed in the Filter Show story:

This multiselect filter:

<Filter label="Multiple status" defaultValue={[]}>
  <FilterItem value="Stable">Stable</FilterItem>
  <FilterItem value="Experimental">Experimental</FilterItem>
  <FilterItem value="Deprecated">Deprecated</FilterItem>
</Filter>

renders the clear button as disabled when it has no value and nothing is selected
image
and still renders it enabled when an item is selected
image
or if it has an item already applied
image

While this single selection filter:

<Filter label="Single status">
  <FilterItem value="Stable">Stable</FilterItem>
  <FilterItem value="Experimental">Experimental</FilterItem>
  <FilterItem value="Deprecated">Deprecated</FilterItem>
</Filter>

still renders as it did before, as expected, here disabled with no value
image
here enabled with an item selected
image
and here enabled with an item already applied
image

@Sophmrs Sophmrs self-assigned this Jan 28, 2025
@Sophmrs Sophmrs requested a review from a team as a code owner January 28, 2025 18:39
Copy link

vercel bot commented Jan 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
shoreline-docs ⬜️ Ignored (Inspect) Jan 28, 2025 6:39pm

@Sophmrs Sophmrs linked an issue Jan 28, 2025 that may be closed by this pull request
Copy link
Contributor

@vaporwavie vaporwavie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work! thanks for the contribution.

@Sophmrs Sophmrs merged commit 3ece22c into main Jan 28, 2025
7 checks passed
@Sophmrs Sophmrs deleted the fix/filter-clear-multiselect branch January 28, 2025 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Filter: Clear button is never disabled with multiple selection
2 participants