Skip to content

fix: preserve child aria-describedby - #542

Merged
yoyo837 merged 1 commit into
react-component:masterfrom
nrps9909:codex/preserve-aria-describedby
Aug 27, 2026
Merged

fix: preserve child aria-describedby#542
yoyo837 merged 1 commit into
react-component:masterfrom
nrps9909:codex/preserve-aria-describedby

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Preserve an existing child aria-describedby when the tooltip is hidden, and compose it with the generated tooltip id while the tooltip is open.

Problem

The current child clone always supplies aria-describedby. When the tooltip is closed it supplies undefined, which removes a description already owned by the child. When the tooltip opens, the generated tooltip id replaces that existing description instead of joining the ARIA ID-reference list.

I found this while validating ant-design/ant-design#59110: a Slider handle passed ariaDescribedByForHandle receives the attribute from rc-slider, but the default Ant Design SliderTooltip wrapper removes it.

Validation

The regression covers the full controlled visibility cycle:

  • hidden: preserves the child description id
  • visible: exposes both the child description and tooltip ids
  • hidden again: restores the child description id

Exact-base behavior fails the first assertion. On this head:

  • npm test -- --runInBand tests/index.test.tsx: 30 tests passed
  • npm run coverage -- --runInBand: 100% statements, branches, functions, and lines
  • npm run tsc
  • npm run lint
  • npx prettier --check src/Tooltip.tsx tests/index.test.tsx
  • npm run compile (ESM, CJS, declarations, and Less assets)
  • git diff --check

AI assistance disclosure: Codex was used to trace the Ant Design integration failure, construct the exact-base regression, and run the validation matrix. The behavior and results above were verified locally.

Summary by CodeRabbit

  • Bug Fixes
    • 优化 Tooltip 的无障碍描述属性处理。
    • 当 Tooltip 显示时,保留并合并子元素已有的描述信息;隐藏时恢复原有属性。
@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@nrps9909 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 27, 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: f2f2ec87-7c89-4201-96da-9bbc9ef85662

📥 Commits

Reviewing files that changed from the base of the PR and between 4cc3d61 and 2f82eb0.

📒 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; 3 remain after this review.


Walkthrough

Tooltip 现在保留子元素已有的 aria-describedby。Tooltip 显示时,代码会合并已有描述 ID 与 mergedId。新增测试覆盖可见性切换。

Changes

Tooltip 描述属性

Layer / File(s) Summary
合并并验证描述属性
src/Tooltip.tsx, tests/index.test.tsx
getChildren 在 Tooltip 显示时合并已有的 aria-describedbymergedId。测试验证隐藏、显示和再次隐藏时的属性值。

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

Merge Risk: ⚪ Minimal · up to 2f82e

This localized change preserves existing child descriptions while composing them with the tooltip description when visible; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: zombiej

Poem

小兔检查描述串,
旧 ID 安静留身旁。
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: preserve child aria-describedby”准确概括了主要变更:保留并合并子元素已有的 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 2…
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 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 (4cc3d61) to head (2f82eb0).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #542   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines           36        38    +2     
  Branches        14        15    +1     
=========================================
+ Hits            36        38    +2     

☔ 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 15fb895 into react-component:master Aug 27, 2026
11 of 12 checks passed
aibayanyu20 added a commit to antdv-next/vue-components that referenced this pull request Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants