-
Notifications
You must be signed in to change notification settings - Fork 41
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
selectedFilters doesn't work for Integer bucket keys #265
Comments
Hello @corovcam , thanks for reporting this issue. I understand the issue with the strict type checking but it was done in purpose so we do not end up with difficult to track bugs due to JS value casting. Could you please elaborate a bit more on your ES filter structure and maybe also showcase what are the values of the |
Hi @zzacharo, thanks for your reply. selectedFilters: [
["metadata_restorationObject_creationPeriod_since", "1550"]
] and the respective buckets being filtered: "buckets": [
{
"key": 1550,
"doc_count": 3,
"label": 1550,
"is_selected": false
},
{
"key": 1700,
"doc_count": 3,
"label": 1700,
"is_selected": false
},
{
"key": 1728,
"doc_count": 3,
"label": 1728,
"is_selected": false
},
{
"key": 1880,
"doc_count": 3,
"label": 1880,
"is_selected": false
},
{
"key": 1500,
"doc_count": 2,
"label": 1500,
"is_selected": false
},
], Also another possible solution could be: selectedFilters.filter((filter) => filter[0] === aggName && filter[1] === value.toString()) |
What about trying to solve this on the Checkbox level i.e when you click on a value it should set as selectedFilter the integer value and not the string. Then the comparison would work as expected. Which component are you using to display the bucket values? The default one or do you have a custom one? |
Describe the bug
selectedFilters.filter((filter) => filter[0] === aggName && filter[1] === value)
This step uses strict comparison between value and type.In case the bucket contains Integer value (key), i.e. year, age, etc., upon bucket click, the checkbox doesn't appear visually checked (the comparison fails). On the other hand, the filter is applied, so the search parameters (and URL) gets updated. The problem lies only in the unset
isSelected
prop that gets passed down to theCheckbox
SemanticUI component.The same problem could potentially happen with other data types: boolean, etc.
I don't think that it's meant for the bucket containing key as integer (or boolean), to also contain bucket.key_as_string property, as seen here:
For example for years or age, or any other number coming from backend.
Expected behavior
Using value comparison only, the issue can be easily solved:
selectedFilters.filter((filter) => filter[0] == aggName && filter[1] == value)
The text was updated successfully, but these errors were encountered: