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(combobox, filter): only test regex on string properties when filtering #4443

Merged
merged 2 commits into from
Apr 25, 2022

Conversation

benelan
Copy link
Member

@benelan benelan commented Apr 23, 2022

Related Issue: #4348

Summary

It was matching the constant attribute's undefined default value.

/u/.test(undefined) === true

Fixing it this way also works for calcite-filter, rather than only filtering based on label and value properties (relevant for #4425)

@benelan benelan requested a review from a team as a code owner April 23, 2022 00:22
@benelan benelan self-assigned this Apr 23, 2022
@github-actions github-actions bot added this to the Sprint 04/25 - 05/6 milestone Apr 23, 2022
@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label Apr 23, 2022
@benelan benelan requested review from Elijbet and jcfranco April 23, 2022 00:23
@@ -158,7 +158,7 @@ export class Filter implements InteractiveComponent {
if (find(val, RE)) {
found = true;
}
} else if (RE.test(val)) {
} else if (typeof val === "string" && RE.test(val)) {
found = true;
Copy link
Member Author

Choose a reason for hiding this comment

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

@jcfranco should this also accept number typed values? Maybe if there is a rating property or something that people want to filter by

Copy link
Member

Choose a reason for hiding this comment

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

The current version changes the filtering behavior, right? I think pick/value list items allow passing metadata objects that go through filtering.

How about returning if the value is null or undefined instead?

if (typeof val === "function" || val == null /* intentional == to catch undefined */) {
  return;
}

if (Array.isArray(val) || typeof val === "object") { /* ... */ }
{ else if (RE.test(val)) { /* ... */ }

Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

💥

@benelan benelan merged commit 0f57c7a into master Apr 25, 2022
@benelan benelan deleted the benelan/4348-combobox-filter-constant-undefined branch April 25, 2022 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports for broken functionality. Issues should include a reproduction of the bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants