patternfly / patternfly/react-data-view
Initial Filters is not respected when array type filter
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
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
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.
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.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100