patternfly / patternfly/react-data-view

Initial Filters is not respected when array type filter

未关闭 适合新手
#671 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
TypeScript
星标
4
派生
21
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 issue 中展示的过滤器逻辑开始,跟踪 URL 键缺失时 array 过滤器和 initialFilters 的加载方式。使用 array 类型的过滤器重现该情况,并验证在不存在 URL 值时,已配置的初始值仍会保留。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
frontend
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
冷清
描述清晰度
描述清楚
新手友好度
68/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。