Initial Filters is not respected when array type filter
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- frontend
Research direction
Start from the filter logic shown in the issue and trace how array filters and initialFilters are loaded when the URL key is absent. Reproduce the case with an array type filter and verify that the configured initial values are retained when no URL values exist.
Written by the indexing model from the issue text.
Description
When the user supplies an array type filter with initialFilters, the initialFilters are never used. The filter logic has the following code:
const urlValue = isArrayFilter ? searchParams?.getAll(key) : searchParams?.get(key);
// eslint-disable-next-line no-nested-ternary
loadedFilters[key] = urlValue
? (isArrayFilter && !Array.isArray(urlValue) ? [ urlValue ] : urlValue)
: initialFilters[key];
The issue is that searchParams.getAll returns an empty array when key doesn't exist, so the truthy check on urlValue evaluates to true even though nothing is set.
This can be resolved by checking the length of the array when isArrayFilter is true
Jira Issue: PF-4302
- Dominant language
- TypeScript
- Stars
- 4
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from patternfly/react-data-view
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
patternfly/react-data-view#692 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
patternfly/react-data-view#680 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
patternfly/react-data-view#662 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
patternfly/react-data-view#676 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
patternfly/react-data-view#646 · 1 comment ·
All issues in patternfly/react-data-view
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·