`Link` marks links to the same page with a different query as `aria-current="page"`
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
调研方向
Start by locating linkActiveAttributes() and the tests for Link active state. Read how it compares the target and current URLs, then check cases with query parameters, reordered parameters, extra current parameters, and links without a query. Done when query-bearing links are marked current only when their parameters match, while query-free menu links retain the described behavior.
由索引模型根据 Issue 内容生成。
描述
Since #676, Link adds aria-current="page" and data-void-active when its destination is the current page. linkActiveAttributes() compares only the pathname ("The query and hash are ignored"). So a link that changes only the query is marked as the current page, even though it leads somewhere else.
Repro (Void 1.6.1)
On /posts?page=2:
<Link href="/posts?page=1">Previous</Link>
<Link href="/posts?page=3">Next</Link>
Both render with aria-current="page" and data-void-active. Screen readers announce "Previous, current page" and "Next, current page". The same happens with any links that change only the query: pagination, previous/next date ranges, sort and filter tabs. A GET link's data merged into its query has the same issue.
Expected
A link whose href has a query is current only when that query matches the current URL. The page itself (/posts?page=2) is the current page; the other two links aren't.
Ignoring the query is still right for links without one. A menu link to /posts should stay current on /posts?page=2 or /posts?sort=new, so that part of the behaviour should stay.
Suggested fix
In linkActiveAttributes(), when the target has a query, also require each of its params to have the same value in the current URL:
const queryMatches = [...target.searchParams].every(
([key, value]) => current.searchParams.getAll(key).includes(value),
);
if (linkPath === currentPath && queryMatches) return { 'aria-current': 'page', 'data-void-active': '' };
Comparing params one by one, instead of the raw search string, means param order doesn't matter. It also keeps a tab link like ?status=open current on ?status=open&page=2. A stricter rule, the whole query must match, would work too.
Another option is a way to opt out, such as activeMatch={false}, though fixing the default is better: most apps won't know their pagination links are announced wrong.
Workaround
Pass aria-current={undefined} on those links, since user attributes win. data-void-active still stays on them.
- 主要语言
- TypeScript
- 星标
- 627
- 派生
- 66
- 平均合并
- 13 小时 57 分钟
- 30 天内合并 PR
- 194
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
voidzero-dev/void 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
voidzero-dev/void#677 ·
维护者通常 1 天内回复
-
Export a guard for `VoidActionError` at every status可能已有人在做 @karthickeyan-dev 今天认领。 未关闭
难度 3/5 1-2 天 新手友好度 78/100
voidzero-dev/void#714 ·
维护者通常 1 天内回复
-
`@void/solid`: `useParams()` keeps the first page's params after client-side navigation可能已有人在做 @yujiym 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 20/100
voidzero-dev/void#708 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 28/100
voidzero-dev/void#692 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 30/100
voidzero-dev/void#689 ·
维护者通常 1 天内回复
查看 voidzero-dev/void 的全部 Issue
相似的 Issue
-
needs-area-label
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
liberation-data/drivine#615 ·
维护者通常 1 天内回复
-
backend bug ready-for-agent
难度 2/5 1-3 小时 新手友好度 78/100
geolens-io/geolens#3639 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
radius-project/ai-extensions#1196 ·
维护者通常 1 天内回复
-
good first issue
难度 1/5 1-3 小时 新手友好度 88/100