Skip to content

fix: show default tooltips on focus - #541

Merged
yoyo837 merged 1 commit into
react-component:masterfrom
nrps9909:codex/show-tooltip-on-focus
Aug 27, 2026
Merged

fix: show default tooltips on focus#541
yoyo837 merged 1 commit into
react-component:masterfrom
nrps9909:codex/show-tooltip-on-focus

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • include focus in Tooltip's default trigger actions
  • expose aria-describedby and mount the tooltip when a keyboard user focuses the default trigger
  • remove the relationship again on blur while leaving explicit trigger configurations unchanged

Closes #496.

Verification

  • Exact-base regression on ba2d690: the focused default trigger had no aria-describedby and the test failed
  • Focused regression: 1 passed
  • Full test suite: 29 passed
  • pnpm lint
  • pnpm tsc
  • pnpm compile (ESM/CJS declarations and Less assets)
  • pnpm build (including docs)
  • git diff --check

AI assistance disclosure: Codex was used to trace the existing accessibility history, check for duplicate PRs, implement the focused fix, and run the verification above. The behavior and results were verified locally.

Summary by CodeRabbit

  • 新功能
    • Tooltip 现在支持通过鼠标悬停或键盘聚焦触发。
    • 聚焦触发时,提示内容会正确关联到触发元素,失去焦点后自动移除关联。

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 603064a4-cfe2-41e5-bcf1-a5973824cab8

📥 Commits

Reviewing files that changed from the base of the PR and between ba2d690 and 2d20ea2.

📒 Files selected for processing (2)
  • src/Tooltip.tsx
  • tests/index.test.tsx

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


Walkthrough

Tooltip 的默认触发方式从仅支持 hover 改为支持 hover 和 focus。新增测试验证焦点时的 Tooltip 内容、aria-describedby 关联,以及失焦后的属性清理。

Changes

Tooltip 默认焦点触发

Layer / File(s) Summary
默认焦点触发与可访问性验证
src/Tooltip.tsx, tests/index.test.tsx
默认触发器同时响应 hoverfocus。测试验证获得焦点时设置 aria-describedby 并关联 Tooltip 内容,失去焦点后移除该属性。

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

Merge Risk: ⚪ Minimal · up to 2d20e

This localized accessibility change adds focus behavior for default tooltips and reports passing tests, lint, type checks, compilation, and builds; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: zombiej

Poem

小兔按键聚焦,

提示悄悄来到。
aria-describedby 连起内容,
失焦后属性轻轻消散。
Hover 与 focus 并肩跳,
Tooltip 现在随键盘闪耀。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题“fix: show default tooltips on focus”准确概括了将默认 Tooltip 触发方式扩展为 focus 的主要变更。
Linked Issues check ✅ Passed PR 实现了 issue #496 的核心目标:默认触发器获得焦点时创建并显示 Tooltip,使 aria-describedby 关联有效;失去焦点后移除关联。新增测试覆盖了焦点和失焦行为。
Out of Scope Changes check ✅ Passed 所有变更都围绕默认 Tooltip 的 focus 支持及其可访问性回归测试展开。未发现与 issue #496 无关的代码变更。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ba2d690) to head (2d20ea2).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #541   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           36        36           
  Branches        14        14           
=========================================
  Hits            36        36           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yoyo837
yoyo837 merged commit 1d4392f into react-component:master Aug 27, 2026
11 of 12 checks passed
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.

Tooltip's lazy initialization undermines accessibility

2 participants