Skip to content

feat: support disabled prop#534

Merged
zombieJ merged 1 commit into
masterfrom
codex/tooltip-disabled
Jul 10, 2026
Merged

feat: support disabled prop#534
zombieJ merged 1 commit into
masterfrom
codex/tooltip-disabled

Conversation

@zombieJ

@zombieJ zombieJ commented Jul 10, 2026

Copy link
Copy Markdown
Member

Summary

  • expose disabled through TooltipProps and pass it to Trigger
  • require @rc-component/trigger@^3.10.0
  • add API documentation, coverage, and an interactive disabled demo

Behavior

Hovering opens the Tooltip. Toggling disabled hides it without resetting the current open state, so enabling it again restores the Tooltip without another mouse enter.

Related: react-component/trigger#638

Validation

  • ut test --runInBand (2 suites, 28 tests)
  • ./node_modules/.bin/tsc --noEmit
  • ut lint (no errors; one existing warning)
  • ut compile
  • ut docs:build
  • ut x prettier@3.6.2 --check package.json src/Tooltip.tsx tests/index.test.tsx docs/examples/disabled.tsx docs/demo/disabled.md

Summary by CodeRabbit

  • 新功能
    • Tooltip 新增 disabled 属性,可临时隐藏提示内容,并支持重新启用。
    • 增加禁用状态示例及交互演示。
  • 文档
    • 补充 Tooltip API 中 disabled 参数的说明,包括类型和默认值。
  • 修复
    • 切换为禁用状态时,Tooltip 可立即隐藏;重新启用后可恢复显示。

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tooltip Ready Ready Preview, Comment Jul 10, 2026 9:29am

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a51e5a5b-7387-4f52-9e8c-fb61567dbc53

📥 Commits

Reviewing files that changed from the base of the PR and between 97804a3 and 09f8f57.

📒 Files selected for processing (6)
  • README.md
  • docs/demo/disabled.md
  • docs/examples/disabled.tsx
  • package.json
  • src/Tooltip.tsx
  • tests/index.test.tsx

Walkthrough

Tooltip 现在支持 disabled 属性,可在保持当前可见状态逻辑的同时临时隐藏提示框。变更包含类型接入、触发器依赖升级、行为测试,以及 API 文档和交互演示。

Changes

Tooltip disabled 支持

Layer / File(s) Summary
Disabled 属性契约与触发器集成
package.json, src/Tooltip.tsx
升级 @rc-component/trigger,并将 disabled 纳入 TooltipProps
Disabled 状态行为验证
tests/index.test.tsx
验证切换 disabled 时 Tooltip 隐藏并可恢复,且不依赖 mouse leave。
Disabled 演示与 API 文档
README.md, docs/examples/disabled.tsx, docs/demo/disabled.md
补充 API 参数说明,并新增可切换 Tooltip 禁用状态的演示。

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

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant DisabledDemo
  participant Tooltip
  participant Trigger
  participant TooltipDOM
  User->>DisabledDemo: 点击按钮切换 disabled
  DisabledDemo->>Tooltip: 传入新的 disabled 状态
  Tooltip->>Trigger: 传递 disabled 属性
  Trigger->>TooltipDOM: 添加或移除 rc-tooltip-hidden
Loading

Possibly related PRs

Poem

小兔轻点按钮,提示悄悄藏;
再点一下回来,耳朵沾月光。
disabled 有开有关,
Tooltip 随心变换忙!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/tooltip-disabled

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a 'disabled' prop to the 'Tooltip' component, allowing it to be temporarily hidden without resetting its visibility state, and updates the '@rc-component/trigger' dependency. It also adds a demo, documentation, and a test case. The review feedback suggests improving accessibility compliance by ensuring that the 'aria-describedby' attribute is not applied to the trigger element when the tooltip is disabled, and recommends adding corresponding assertions to the test suite.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/Tooltip.tsx Outdated
TriggerProps,
| 'onPopupAlign'
| 'builtinPlacements'
| 'disabled'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When the disabled prop is true, the tooltip is temporarily hidden, but its internal open state is not reset (as described in the PR description). This means open remains true, which causes aria-describedby to still be applied to the trigger element in getChildren.

To ensure proper accessibility (ARIA) compliance, we should prevent aria-describedby from being set when the tooltip is disabled.

We can achieve this by:

  1. Destructuring disabled from props in Tooltip.tsx.
  2. Explicitly passing disabled to <Trigger>.
  3. Updating getChildren to check !disabled before setting aria-describedby.

Here is how the implementation would look:

// 1. Destructure `disabled` from props (around line 83)
const {
  // ... other props
  disabled,
  ...restProps
} = props;

// 2. Update getChildren (around line 117)
const getChildren: TriggerProps['children'] = ({ open }) => {
  const child = React.Children.only(children);
  const ariaProps: React.AriaAttributes = {
    'aria-describedby': overlay && open && !disabled ? mergedId : undefined,
  };
  return React.cloneElement(child, ariaProps);
};

// 3. Pass disabled to Trigger (around line 158)
<Trigger
  // ... other props
  disabled={disabled}
  {...extraProps}
>

Comment thread tests/index.test.tsx
Comment on lines +323 to +330
fireEvent.mouseEnter(button);
expect(container.querySelector('.rc-tooltip')).not.toHaveClass('rc-tooltip-hidden');

fireEvent.click(button);
expect(container.querySelector('.rc-tooltip')).toHaveClass('rc-tooltip-hidden');

fireEvent.click(button);
expect(container.querySelector('.rc-tooltip')).not.toHaveClass('rc-tooltip-hidden');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To verify that the accessibility attributes (aria-describedby) are correctly managed when the tooltip is disabled, we should add assertions for aria-describedby in this test case.

Suggested change
fireEvent.mouseEnter(button);
expect(container.querySelector('.rc-tooltip')).not.toHaveClass('rc-tooltip-hidden');
fireEvent.click(button);
expect(container.querySelector('.rc-tooltip')).toHaveClass('rc-tooltip-hidden');
fireEvent.click(button);
expect(container.querySelector('.rc-tooltip')).not.toHaveClass('rc-tooltip-hidden');
fireEvent.mouseEnter(button);
expect(container.querySelector('.rc-tooltip')).not.toHaveClass('rc-tooltip-hidden');
expect(button).toHaveAttribute('aria-describedby');
fireEvent.click(button);
expect(container.querySelector('.rc-tooltip')).toHaveClass('rc-tooltip-hidden');
expect(button).not.toHaveAttribute('aria-describedby');
fireEvent.click(button);
expect(container.querySelector('.rc-tooltip')).not.toHaveClass('rc-tooltip-hidden');
expect(button).toHaveAttribute('aria-describedby');

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (97804a3) to head (09f8f57).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #534   +/-   ##
=========================================
  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.

@zombieJ zombieJ force-pushed the codex/tooltip-disabled branch from 2b32efb to 09f8f57 Compare July 10, 2026 09:28
@github-actions

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 09f8f57.

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

❌ Deploy failed

PR preview ❌ Failed ❌ Failed
🔗 Preview https://react-component-tooltip-preview-pr-534.surge.sh (may be unavailable)
📝 Commit09f8f57
🪵 LogsView logs
📋 Build log (last lines)
npm error
npm error Could not resolve dependency:
npm error peer eslint@"^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" from eslint-plugin-react@7.37.5
npm error node_modules/eslint-plugin-react
npm error   dev eslint-plugin-react@"^7.37.5" from the root project
npm error   eslint-plugin-react@"^7.32.2" from @umijs/fabric@4.0.1
npm error   node_modules/@umijs/fabric
npm error     @umijs/fabric@"^4.0.0" from rc-test@7.1.3
npm error     node_modules/rc-test
npm error       dev rc-test@"^7.1.3" from the root project
npm error
npm error Conflicting peer dependency: eslint@9.39.4
npm error node_modules/eslint
npm error   peer eslint@"^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7" from eslint-plugin-react@7.37.5
npm error   node_modules/eslint-plugin-react
npm error     dev eslint-plugin-react@"^7.37.5" from the root project
npm error     eslint-plugin-react@"^7.32.2" from @umijs/fabric@4.0.1
npm error     node_modules/@umijs/fabric
npm error       @umijs/fabric@"^4.0.0" from rc-test@7.1.3
npm error       node_modules/rc-test
npm error         dev rc-test@"^7.1.3" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /home/runner/.npm/_logs/2026-07-10T09_30_29_576Z-eresolve-report.txt
npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2026-07-10T09_30_29_576Z-debug-0.log

🤖 Powered by surge-preview

@zombieJ zombieJ marked this pull request as ready for review July 10, 2026 09:46
@zombieJ zombieJ merged commit 584b731 into master Jul 10, 2026
15 checks passed
@zombieJ zombieJ deleted the codex/tooltip-disabled branch July 10, 2026 09:47
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