Skip to content

selectedFilters doesn't work for Integer bucket keys #265

@corovcam

Description

@corovcam

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 the Checkbox 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:

const keyField = bucket.key_as_string ? bucket.key_as_string : bucket.key;
const isSelected = this._isSelected(this.aggName, keyField, selectedFilters);

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions