Skip to content

fix: include links with an empty href in focus list - #824

Open
Aminark wants to merge 2 commits into
react-component:masterfrom
Aminark:fix/focus-empty-href
Open

Aminark wants to merge 2 commits into
react-component:masterfrom
Aminark:fix/focus-empty-href

Conversation

@Aminark

@Aminark Aminark commented Oct 25, 2026 •

Copy link
Copy Markdown

An <a href=""> is focusable, but getFocusNodeList skips it because it checks whether the attribute value is truthy. This also leaves the link out of focus-lock navigation.

Check for the attribute instead. The regression test covers an empty href, an anchor without href, and tabindex="-1" with and without includeNegative.

All 32 suites pass (229 tests, 1 existing skip); the new test fails before the fix. TypeScript, lint (13 existing warnings), formatting, and the package build pass.

Summary by CodeRabbit

  • 修复
    • 修正空 href 链接的焦点处理,使其能正确出现在焦点列表中,并可按 tabIndex 设置筛选。

@vercel

vercel Bot commented Oct 25, 2026

Copy link
Copy Markdown

@Aminark is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b7bfe1ee-92ab-414e-a215-76756932eb71
Commits

Reviewing files that changed from the base of the PR and between e12854b and 61b0090.

Files selected for processing: 2
  • src/Dom/focus.ts
  • tests/focus.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Walkthrough

链接的可聚焦判断改为检查是否存在 href 属性。新增测试验证空 href 链接在默认焦点列表、负 tabIndex 列表及实际焦点设置中的行为。

Changes

空 href 链接焦点处理

Layer / File(s) Summary
更新链接焦点判断并验证
src/Dom/focus.ts, tests/focus.test.tsx
焦点判断改为检查链接是否具有 href 属性。新增测试覆盖空 href 链接的默认焦点列表、负 tabIndex 列表和实际焦点设置。

Priority: Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: Minimal · up to 61b00

No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 标题“fix: include links with an empty href in focus list”描述了本 PR 的主要变更:焦点列表现在包含 href 为空的链接。raw_summary 显示 src/Dom/focus.ts 将 focusable 的判断从读取 href 值改为 hasAttribute('href'),并新增测试覆盖空 href 链接。pr_objectives…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

标题“fix: include links with an empty href in focus list”描述了本 PR 的主要变更:焦点列表现在包含 href 为空的链接。raw_summary 显示 src/Dom/focus.ts 将 focusable 的判断从读取 href 值改为 hasAttribute('href'),并新增测试覆盖空 href 链接。pr_objectives 也指出 getFocusNodeList 之前因检查属性值的真假而跳过 <a href="">,本 PR 改为检查属性是否存在。标题与变更内容一致,且具体。

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

小兔看见空链接,
也能轻轻跳进焦点里。
列表记下它的位置,
负索引时另有记录。
测试收好小树枝,
小兔蹦蹦回家去。

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant