Skip to content

fix: set aria-describedby when overlay is a false but valid node - #544

Open
zigzagdev wants to merge 1 commit into
react-component:masterfrom
zigzagdev:fix/tooltip-overlay-falsy-aria-describedby
Open

fix: set aria-describedby when overlay is a false but valid node#544
zigzagdev wants to merge 1 commit into
react-component:masterfrom
zigzagdev:fix/tooltip-overlay-falsy-aria-describedby

Conversation

@zigzagdev

@zigzagdev zigzagdev commented Aug 31, 2026

Copy link
Copy Markdown

Summary

Motivation

  • getChildren decided whether to attach aria-describedby using overlay && open, so a falsy-but-valid overlay (e.g. overlay={0}) was rendered visibly by Popup but never got an aria-describedby reference, leaving the accessible relationship out of sync with what's on screen.

What I have done

  • Changed the check to overlay != null && open so only "no overlay provided" (null/undefined) skips the attribute, while any other renderable value (including 0 or '') still gets described correctly when it open.

Test plan

  • rc-test tests/index.test.tsx — all 29 existing tests pass (run in a Docker node:20 container since local node_modules wasn't installed)

Summary by CodeRabbit

  • Bug Fixes
    • 修复提示浮层打开时 aria-describedby 标识未能正确添加的问题。
    • 现在即使浮层内容为空值字符串,只要浮层存在且处于打开状态,也能正确关联辅助功能描述。

overlay values like 0 are valid renderable content, but the previous
`overlay && open` check treated them as absent and skipped
aria-describedby even while the tooltip was visible.
@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

@zigzagdev 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 Aug 31, 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: Team

Run ID: 6f611c3c-cd88-44bb-8853-ee62a90a4751

📥 Commits

Reviewing files that changed from the base of the PR and between a43ecc7 and a2629bf.

📒 Files selected for processing (1)
  • src/Tooltip.tsx

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


Walkthrough

Changes

Tooltip 可访问性属性

Layer / File(s) Summary
调整 aria-describedby 条件
src/Tooltip.tsx
overlay != null && open 时,aria-describedby 数组包含 mergedId。空字符串等非 null/undefined 的 overlay 也满足该条件。

Estimated code review effort: 1 (简单) | ~5 分钟

Merge Risk: ⚪ Minimal · up to a2629

This change keeps the accessibility reference synchronized for valid falsy overlay content and is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

Suggested reviewers: nrps9909, zombiej

Poem

小兔看见提示层,
描述标识轻轻生。
非空弹层门打开,
空串也能留其名。
可访问性更分明。

🚥 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 标题准确描述了主要变更:当 overlay 是有效但为假值的节点时设置 aria-describedby
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 1…
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: 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 1 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.

@yoyo837

yoyo837 commented Sep 1, 2026

Copy link
Copy Markdown
Member

Need some test case to cover this.

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.

2 participants