Skip to content

feat: Modal support focusable#56500

Merged
zombieJ merged 5 commits intofeaturefrom
focuable
Jan 6, 2026
Merged

feat: Modal support focusable#56500
zombieJ merged 5 commits intofeaturefrom
focuable

Conversation

@zombieJ
Copy link
Member

@zombieJ zombieJ commented Jan 6, 2026

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

  • Describe the source of related requirements, such as links to relevant issue discussions.
  • For example: close #xxxx, fix #xxxx

💡 Background and Solution

  • The specific problem to be addressed.
  • List the final API implementation and usage if needed.
  • If there are UI/interaction changes, consider providing screenshots or GIFs.

📝 Change Log

Language Changelog
🇺🇸 English Modal support focusable.trap to enable config focus lock in the Modal or not.
🇨🇳 Chinese Modal 支持 focusable.trap 以配置是否将焦点锁定在 Modal 内部。

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 6, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch focuable

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 and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

Preview is ready

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

👁 Visual Regression Report for PR #56500 Failed ❌

🎯 Target branch: feature (f7a216a)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎
📊 Summary: 🔄 3 changed

Expected (Branch feature) Actual (Current PR) Diff
color-picker-pure-panel.dark.png color-picker-pure-panel.dark.png color-picker-pure-panel.dark.png color-picker-pure-panel.dark.png
slider-show-tooltip.dark.png slider-show-tooltip.dark.png slider-show-tooltip.dark.png slider-show-tooltip.dark.png
table-sticky.default.png table-sticky.default.png table-sticky.default.png table-sticky.default.png

Important

There are 3 diffs found in this PR: 🔄 3 changed.
Please check all items:

  • Visual diff is acceptable

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @zombieJ, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the accessibility and user experience of the Modal component by introducing a new focusable prop. This prop centralizes and expands control over focus behavior, allowing developers to easily configure focus trapping within the modal and manage where focus returns after the modal closes. This change streamlines focus management, deprecating older, separate props for a more unified and flexible API.

Highlights

  • New focusable Prop for Modals: Introduced a new focusable prop for the Modal and Modal.confirm components, allowing for more granular control over focus management within modals.
  • Focus Trap Configuration: The focusable prop now includes a trap sub-property, enabling developers to configure whether focus should be locked within the modal, enhancing accessibility.
  • Deprecated Focus Props: The focusTriggerAfterClose prop for Modal and autoFocusButton for Modal.confirm have been deprecated in favor of focusable.focusTriggerAfterClose and focusable.autoFocusButton respectively, consolidating focus-related configurations.
  • Reused useFocusable Hook: The useFocusable hook, previously used in the Drawer component, has been adapted and reused for Modal to provide consistent focus management logic.
  • Dependency Update: The @rc-component/dialog dependency has been updated from ~1.7.0 to ~1.8.0, likely bringing in improvements or necessary changes for the new focus features.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@socket-security
Copy link

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

size-limit report 📦

Path Size
dist/antd.min.js 522.99 KB (+120 B 🔺)
dist/antd-with-locales.min.js 616.39 KB (+117 B 🔺)

Copy link
Contributor

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

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 new focusable prop to the Modal component to centralize focus management settings, deprecating older props like focusTriggerAfterClose and autoFocusButton. The changes are well-structured, including updates to hooks, interfaces, documentation, and tests. My review includes a critical fix for a logic bug in how focus settings are merged and a suggestion to improve type definitions for better maintainability.

Comment on lines +107 to +110
const mergedAutoFocusButton = React.useMemo(() => {
const base = focusable?.autoFocusButton || autoFocusButton;
return base || base === null ? base : 'ok';
}, [autoFocusButton, focusable?.autoFocusButton]);
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The logic for determining mergedAutoFocusButton has a bug and could be simplified. Using the logical OR operator (||) causes focusable.autoFocusButton: null to be ignored, incorrectly falling back to the legacy autoFocusButton prop. You should use the nullish coalescing operator (??) to correctly prioritize the focusable prop. The logic can also be made more readable.

Suggested change
const mergedAutoFocusButton = React.useMemo(() => {
const base = focusable?.autoFocusButton || autoFocusButton;
return base || base === null ? base : 'ok';
}, [autoFocusButton, focusable?.autoFocusButton]);
const mergedAutoFocusButton = React.useMemo(() => {
const base = focusable?.autoFocusButton ?? autoFocusButton;
return base === undefined ? 'ok' : base;
}, [autoFocusButton, focusable]);

Comment on lines +186 to +188
focusable?: FocusableConfig & {
autoFocusButton?: null | 'ok' | 'cancel';
};
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better code clarity and maintainability, consider defining a dedicated interface for the focusable prop in ModalFuncProps instead of using an inline intersection type. This makes the type easier to read and reuse.

You could define it like this earlier in the file:

export interface ModalFocusableConfig extends FocusableConfig {
  autoFocusButton?: null | 'ok' | 'cancel';
}

And then use it within ModalFuncProps:

// ...
  focusable?: ModalFocusableConfig;
// ...

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 6, 2026

@blacksmith-sh

This comment has been minimized.

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (feature@1ec7cd7). Learn more about missing BASE report.
⚠️ Report is 3 commits behind head on feature.

Additional details and impacted files
@@             Coverage Diff             @@
##             feature    #56500   +/-   ##
===========================================
  Coverage           ?   100.00%           
===========================================
  Files              ?       807           
  Lines              ?     14870           
  Branches           ?      3931           
===========================================
  Hits               ?     14870           
  Misses             ?         0           
  Partials           ?         0           

☔ View full report in Codecov by Sentry.
📢 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.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 6, 2026
@zombieJ zombieJ merged commit 0cdfaf5 into feature Jan 6, 2026
60 of 61 checks passed
@zombieJ zombieJ deleted the focuable branch January 6, 2026 06:34
@zombieJ zombieJ mentioned this pull request Jan 13, 2026
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants