Skip to content

fix(drawer): support closable placement configuration from ConfigProvider#55985

Merged
meet-student merged 14 commits intoant-design:masterfrom
meet-student:patch-drawer
Dec 9, 2025
Merged

fix(drawer): support closable placement configuration from ConfigProvider#55985
meet-student merged 14 commits intoant-design:masterfrom
meet-student:patch-drawer

Conversation

@meet-student
Copy link
Member

@meet-student meet-student commented Nov 28, 2025

中文版模板 / 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

💡 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 support closable placement configuration from ConfigProvider
🇨🇳 Chinese 修复 closable placement 配置在 ConfigProvider 组件下失效

@bolt-new-by-stackblitz
Copy link

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

@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2025

Preview is ready

@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2025

👁 Visual Regression Report for PR #55985 Failed ❌

🎯 Target branch: master (56c7c9f)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎
📊 Summary: 🔄 1 changed

Expected (Branch master) Actual (Current PR) Diff
table-sticky.dark.png table-sticky.dark.png table-sticky.dark.png table-sticky.dark.png

Important

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

  • Visual diff is acceptable

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @meet-student, 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 introduces a crucial bug fix for the Drawer component, specifically addressing an oversight where the closable button's placement configuration was not being respected when defined globally through the ConfigProvider. The changes ensure that the component correctly inherits and applies these configuration settings, while also maintaining the expected behavior of allowing local component props to take precedence over global configurations. This improves the flexibility and consistency of Drawer component customization across applications.

Highlights

  • Bug Fix: Resolved an issue where the closable placement configuration for the Drawer component was not being correctly applied when set via the ConfigProvider.
  • ConfigProvider Integration: The Drawer component now properly reads and merges the closable placement setting from the ConfigProvider, allowing for centralized configuration.
  • Prop Overriding: Individual Drawer component props for closable placement will now correctly override the settings provided by the ConfigProvider.
  • Test Coverage: New test cases have been added to ensure the correct behavior of closable placement when configured through ConfigProvider and when overridden by component props.
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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 28, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Summary by CodeRabbit

发布说明

  • 新功能

    • 支持通过配置提供器统一配置抽屉组件的关闭按钮位置(开始或结束)。
  • 文档

    • 更新配置提供器文档,说明关闭按钮位置配置选项。

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

将 Drawer 的 closable 来源扩展为优先使用组件 prop,缺省时回退到 drawerContext 的 contextClosable,用 useMemo 计算 closablePlacement('start'/'end'/undefined),并据此调整头部关闭图标渲染;同时补充相关测试与 ConfigProvider 文档项。

Changes

Cohort / File(s) 变更摘要
核心逻辑修复
components/drawer/DrawerPanel.tsx
drawerContext 提取 contextClosable,将组件 prop 与上下文合并为 closable ?? contextClosable 传入 useMergeSemantic,并用 useMemo 计算 closablePlacement('start'/'end'/undefined),替换此前的显式分支逻辑以决定头部关闭图标位置与渲染路径。
测试覆盖扩展
components/drawer/__tests__/Drawer.test.tsx
重新格式化参数化测试;新增 should support closable placement config from ConfigProvider 测试,验证 ConfigProvider 中的 closable.placement(默认、start)和组件 prop 覆盖行为,以及对应的关闭按钮类名与存在性。
文档更新
components/config-provider/index.en-US.md, components/config-provider/index.zh-CN.md
在 ConfigProvider 的 Drawer 配置表中新增 closable?: DrawerProps["closable"] 字段,并在 Drawer 的通用属性说明中列出 closable 以支持通过 ConfigProvider 配置关闭按钮位置。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 分钟

  • 需重点检查:
    • 合并逻辑在不同类型(boolean / object / undefined)输入下的优先级与行为是否正确。
    • useMemo 依赖数组是否包含所有相关变量(closable, contextClosable 等)。
    • useMergeSemantic 调用处接收合并后值的预期契约是否保持不变。
    • 新增测试用例的覆盖是否完整(默认、上下文、prop 覆盖三种情况)及断言的准确性。

Poem

🐰 抽屉左右细斟酌,
上下文与道具轻相和,
合并判断不慌张,
memo 守位又稳妥,
小兔跳跃送把握!

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed 标题清晰准确地描述了主要变更:从 ConfigProvider 支持 closable placement 配置,与代码改动直接相关。
Description check ✅ Passed 描述与变更相关,明确指出这是修复 Drawer 中 ConfigProvider 的 closable placement 配置问题。
Linked Issues check ✅ Passed 代码变更完全满足 #55963 的需求:(1) DrawerPanel 从上下文提取 contextClosable 并合并配置;(2) 使用 useMemo 计算 closablePlacement;(3) 添加测试验证 ConfigProvider 配置覆盖;(4) 更新英文和中文文档说明 closable 属性。
Out of Scope Changes check ✅ Passed 所有变更都在范围内:核心逻辑修复、测试用例、文档更新均直接对应 #55963 的需求,无额外的无关改动。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 32608b3 and 92e5cef.

📒 Files selected for processing (3)
  • components/config-provider/index.en-US.md (1 hunks)
  • components/config-provider/index.zh-CN.md (1 hunks)
  • components/drawer/DrawerPanel.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/config-provider/index.zh-CN.md
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always use TypeScript with strict type checking
Never use any type - define precise types instead
Use interfaces (not type aliases) for object structures
Export all public interface types
Prefer union types over enums, use as const for constants
Use early returns to improve readability
Support tree shaking
Follow import order: React → dependencies → antd components → custom components → types → styles
Prefer antd built-in components over external dependencies
Pass all ESLint and TypeScript checks
No console errors or warnings

**/*.{ts,tsx}: Use camelCase for property names
All components and functions must provide accurate type definitions
Avoid using any type, define types as precisely as possible
Use interface rather than type alias for defining object structures
All TypeScript should compile without errors or warnings
Use generics appropriately to enhance type flexibility
Use intersection types (&) to merge multiple types
Use literal union types to define limited option sets
Avoid using enum, prefer union types and as const
Rely on TypeScript's type inference as much as possible
Use type assertions (as) only when necessary
Complex data structures should be split into multiple interface definitions
Avoid outdated APIs and keep updated to new recommended usage

Files:

  • components/drawer/DrawerPanel.tsx
components/**/*.tsx

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

components/**/*.tsx: Component props interfaces should be named ComponentNameProps
Component ref types should use React.ForwardRefRenderFunction
Use functional components with hooks exclusively (no class components)
Apply performance optimizations with React.memo, useMemo, useCallback appropriately
Support server-side rendering
Components must support ref forwarding with structure including nativeElement, focus, and other methods
Use PascalCase for component names
Use camelCase for props with specific patterns: default + PropName for defaults, forceRender for force rendering, open instead of visible for panel state, show + PropName for display toggles, PropName + able for capabilities, dataSource for data source, disabled for disabled state, extra for additional content, icon for icons, trigger for triggers, className for CSS classes
Use on + EventName pattern for event handlers (e.g., onClick, onChange)
Use on + SubComponentName + EventName pattern for sub-component events
Use complete names, never abbreviations in prop naming
Optimize for minimal re-renders
Use useLocale hook from components/locale/index.tsx
Support accessibility (WCAG 2.1 AA)

Files:

  • components/drawer/DrawerPanel.tsx
components/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Never hardcode colors, sizes, or spacing values

components/**/*.{ts,tsx}: Use TypeScript and React for component development
Use functional components and hooks, avoid class components
Use PascalCase for component names
Use complete names rather than abbreviations in component naming
Initialize properties should use default + PropName naming pattern
Panel opening should use open prop instead of visible
Event handlers should follow on + EventName naming pattern
Child component events should follow on + SubComponentName + EventName naming pattern
Components should provide a ref attribute with nativeElement and focus methods
Export all public interface types for user convenience
Component props should use interface definition named ComponentNameProps
Use CSS transitions for simple animations, rc-motion for complex animations
Respect user's prefers-reduced-motion setting for animations
Follow WCAG 2.1 AA level accessibility standards for styling
Achieve 100% test coverage
Use useLocale hook from components/locale/index.tsx to get localization configuration
Use React.memo, useMemo, and useCallback appropriately for performance optimization
Use React.ForwardRefRenderFunction for component ref types
Callback function types should have explicit parameter and return value definitions
Component state should have dedicated interfaces (e.g., ComponentNameState)
Components should display well on different screen sizes (responsive design)
Components should support right-to-left (RTL) reading direction
Support page zoom to 200% with normal layout
Avoid animations that cause flickering
Ensure code runs normally with no console errors
Avoid unnecessary re-renders
Support Tree Shaking for bundle optimization

Files:

  • components/drawer/DrawerPanel.tsx
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use 2-space indentation

Files:

  • components/drawer/DrawerPanel.tsx
  • components/config-provider/index.en-US.md
**/*.{ts,tsx,css}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Maintain cross-browser compatibility

Files:

  • components/drawer/DrawerPanel.tsx
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js}: Use early returns to improve code readability
Pass all ESLint and TypeScript checks

Files:

  • components/drawer/DrawerPanel.tsx
components/*/*.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

components/*/*.md: Provide both English and Chinese documentation
When documenting component APIs, use table structure with string defaults in backticks, boolean defaults as literal values, number defaults as literal values, no default value as -, descriptions starting with capital letter without ending period, properties sorted alphabetically

Files:

  • components/config-provider/index.en-US.md
components/**/*.md

📄 CodeRabbit inference engine (AGENTS.md)

components/**/*.md: Markdown documentation should have Chinese headings with manual English anchor IDs in format: ## 中文标题 {#english-anchor-id}
New properties should declare the version number they become available in documentation

Files:

  • components/config-provider/index.en-US.md
**/*.md

📄 CodeRabbit inference engine (AGENTS.md)

**/*.md: Anchor IDs must match regex ^[a-zA-Z][\w-:\.]*$ and not exceed 32 characters (except for demo IDs containing -demo-)
FAQ section headings should have anchor IDs prefixed with faq-
Same topics in Chinese and English documentation should use identical anchor IDs
Provide both Chinese and English versions for documentation

Files:

  • components/config-provider/index.en-US.md
🧠 Learnings (3)
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/**/*.tsx : Use camelCase for props with specific patterns: `default` + `PropName` for defaults, `forceRender` for force rendering, `open` instead of `visible` for panel state, `show` + `PropName` for display toggles, `PropName` + `able` for capabilities, `dataSource` for data source, `disabled` for disabled state, `extra` for additional content, `icon` for icons, `trigger` for triggers, `className` for CSS classes

Applied to files:

  • components/config-provider/index.en-US.md
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/demo/*.tsx : Demo code import order: React → dependencies → antd components → custom components → types → styles

Applied to files:

  • components/config-provider/index.en-US.md
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Support React 16 ~ 19 versions

Applied to files:

  • components/config-provider/index.en-US.md
🧬 Code graph analysis (1)
components/drawer/DrawerPanel.tsx (1)
components/_util/hooks/useMergeSemantic.ts (1)
  • useMergeSemantic (118-152)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: build preview
  • GitHub Check: test lib/es module (es, 1/2)
  • GitHub Check: test lib/es module (es, 2/2)
  • GitHub Check: build
  • GitHub Check: lint
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: test-react-legacy (18, 2/2)
  • GitHub Check: test-node
  • GitHub Check: test-react-legacy (18, 1/2)
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: visual-diff snapshot (1/2)
  • GitHub Check: build
  • GitHub Check: size
🔇 Additional comments (3)
components/drawer/DrawerPanel.tsx (2)

85-99: LGTM!正确提取并合并 context 配置

drawerContext 提取 contextClosable 并通过 closable ?? contextClosable 合并到 useMergeSemantic 的实现是正确的。这确保了组件 props 优先于 ConfigProvider 配置。


102-115: LGTM!closablePlacement 计算逻辑正确

useMemo 实现正确处理了所有情况:

  • false 时返回 undefined
  • 对象且 placement === 'end' 时返回 'end'
  • 其他情况默认返回 'start'

之前评审中提到的 null 检查问题已通过 mergedClosableVal && 正确修复。

components/config-provider/index.en-US.md (1)

130-130: 修复链接并添加 closable 版本号

存在两个文档问题:

  1. 链接错误:在英文文档中使用了中文文档链接 /components/drawer-cn#api,应改为 /components/drawer#api
  2. 缺少版本号:根据编码规范,新增的属性需要在文档中声明可用版本号
-| drawer | Set Drawer common props | { className?: string, style?: React.CSSProperties, classNames?: [DrawerProps\["classNames"\]](/components/drawer#semantic-dom), styles?: [DrawerProps\["styles"\]](/components/drawer#semantic-dom), closeIcon?: ReactNode, closable?: [DrawerProps\["closable"\]](/components/drawer-cn#api) } | - | 5.7.0, `classNames` and `styles`: 5.10.0, `closeIcon`: 5.14.0 |
+| drawer | Set Drawer common props | { className?: string, style?: React.CSSProperties, classNames?: [DrawerProps\["classNames"\]](/components/drawer#semantic-dom), styles?: [DrawerProps\["styles"\]](/components/drawer#semantic-dom), closeIcon?: ReactNode, closable?: [DrawerProps\["closable"\]](/components/drawer#api) } | - | 5.7.0, `classNames` and `styles`: 5.10.0, `closeIcon`: 5.14.0, `closable`: 5.x.x |

请将 5.x.x 替换为实际发布版本号。

⛔ Skipped due to learnings
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/*/*.md : Provide both English and Chinese documentation

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.

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 correctly fixes an issue where the closable placement configuration from ConfigProvider was not being applied to the Drawer component. The changes in DrawerPanel.tsx properly merge the closable prop from both the component props and the context, with the component prop taking precedence. New tests have been added to verify this behavior.

My review includes a couple of suggestions for improvement:

  • A defensive null check to prevent potential runtime errors.
  • A small fix in the new test case to ensure proper cleanup, improving test suite stability.

meet-student and others added 2 commits November 29, 2025 00:04
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: 遇见同学 <1875694521@qq.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: 遇见同学 <1875694521@qq.com>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 28, 2025

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
components/drawer/__tests__/Drawer.test.tsx (1)

580-636: ConfigProvider 下 closable placement 行为测试覆盖完整,但断言风格可略作统一

优点:

  • 分别验证了:
    • 仅通过 ConfigProvider 配置 placement: 'end' 时,关闭按钮带有 .ant-drawer-close-end 类(Line 585–597)。
    • 仅通过 ConfigProvider 配置 placement: 'start' 时,没有 -end 类(Line 603–617)。
    • Drawer closable props 显式传入 placement: 'start' 时,覆盖掉 ConfigProvider 中的 placement: 'end'(Line 623–635)。
  • 每个 render 分支都获取了 unmountX 并在用例尾部调用,避免对其他用例的 DOM / 定时器产生影响,这一点很好。

可以考虑的小优化(可选):

  • expect(closeButtonX).toBeTruthy()expect(...).toBeFalsy() 改为 toBeInTheDocument() / toBeNull(),与上文 should support closable placement with start/end 测试保持一致的 jest-dom 断言风格,会更直观一些,但不是功能性问题。

整体来看,该测试很好地锁定了本次修复的核心行为。

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd79fd4 and 4c8720b.

📒 Files selected for processing (2)
  • components/drawer/DrawerPanel.tsx (2 hunks)
  • components/drawer/__tests__/Drawer.test.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always use TypeScript with strict type checking
Never use any type - define precise types instead
Use interfaces (not type aliases) for object structures
Export all public interface types
Prefer union types over enums, use as const for constants
Use early returns to improve readability
Support tree shaking
Follow import order: React → dependencies → antd components → custom components → types → styles
Prefer antd built-in components over external dependencies
Pass all ESLint and TypeScript checks
No console errors or warnings

**/*.{ts,tsx}: Use camelCase for property names
All components and functions must provide accurate type definitions
Avoid using any type, define types as precisely as possible
Use interface rather than type alias for defining object structures
All TypeScript should compile without errors or warnings
Use generics appropriately to enhance type flexibility
Use intersection types (&) to merge multiple types
Use literal union types to define limited option sets
Avoid using enum, prefer union types and as const
Rely on TypeScript's type inference as much as possible
Use type assertions (as) only when necessary
Complex data structures should be split into multiple interface definitions
Avoid outdated APIs and keep updated to new recommended usage

Files:

  • components/drawer/__tests__/Drawer.test.tsx
  • components/drawer/DrawerPanel.tsx
components/**/*.tsx

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

components/**/*.tsx: Component props interfaces should be named ComponentNameProps
Component ref types should use React.ForwardRefRenderFunction
Use functional components with hooks exclusively (no class components)
Apply performance optimizations with React.memo, useMemo, useCallback appropriately
Support server-side rendering
Components must support ref forwarding with structure including nativeElement, focus, and other methods
Use PascalCase for component names
Use camelCase for props with specific patterns: default + PropName for defaults, forceRender for force rendering, open instead of visible for panel state, show + PropName for display toggles, PropName + able for capabilities, dataSource for data source, disabled for disabled state, extra for additional content, icon for icons, trigger for triggers, className for CSS classes
Use on + EventName pattern for event handlers (e.g., onClick, onChange)
Use on + SubComponentName + EventName pattern for sub-component events
Use complete names, never abbreviations in prop naming
Optimize for minimal re-renders
Use useLocale hook from components/locale/index.tsx
Support accessibility (WCAG 2.1 AA)

Files:

  • components/drawer/__tests__/Drawer.test.tsx
  • components/drawer/DrawerPanel.tsx
components/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Never hardcode colors, sizes, or spacing values

components/**/*.{ts,tsx}: Use TypeScript and React for component development
Use functional components and hooks, avoid class components
Use PascalCase for component names
Use complete names rather than abbreviations in component naming
Initialize properties should use default + PropName naming pattern
Panel opening should use open prop instead of visible
Event handlers should follow on + EventName naming pattern
Child component events should follow on + SubComponentName + EventName naming pattern
Components should provide a ref attribute with nativeElement and focus methods
Export all public interface types for user convenience
Component props should use interface definition named ComponentNameProps
Use CSS transitions for simple animations, rc-motion for complex animations
Respect user's prefers-reduced-motion setting for animations
Follow WCAG 2.1 AA level accessibility standards for styling
Achieve 100% test coverage
Use useLocale hook from components/locale/index.tsx to get localization configuration
Use React.memo, useMemo, and useCallback appropriately for performance optimization
Use React.ForwardRefRenderFunction for component ref types
Callback function types should have explicit parameter and return value definitions
Component state should have dedicated interfaces (e.g., ComponentNameState)
Components should display well on different screen sizes (responsive design)
Components should support right-to-left (RTL) reading direction
Support page zoom to 200% with normal layout
Avoid animations that cause flickering
Ensure code runs normally with no console errors
Avoid unnecessary re-renders
Support Tree Shaking for bundle optimization

Files:

  • components/drawer/__tests__/Drawer.test.tsx
  • components/drawer/DrawerPanel.tsx
**/__tests__/**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/__tests__/**/*.test.{ts,tsx}: Write comprehensive tests using Jest and React Testing Library
Include snapshot tests for UI components

**/__tests__/**/*.test.{ts,tsx}: Test files should be named index.test.tsx or xxx.test.tsx and placed in tests directory
Use snapshot testing for UI components

Files:

  • components/drawer/__tests__/Drawer.test.tsx
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use 2-space indentation

Files:

  • components/drawer/__tests__/Drawer.test.tsx
  • components/drawer/DrawerPanel.tsx
**/*.{ts,tsx,css}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Maintain cross-browser compatibility

Files:

  • components/drawer/__tests__/Drawer.test.tsx
  • components/drawer/DrawerPanel.tsx
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js}: Use early returns to improve code readability
Pass all ESLint and TypeScript checks

Files:

  • components/drawer/__tests__/Drawer.test.tsx
  • components/drawer/DrawerPanel.tsx
**/__tests__/**/*.{test,spec}.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Jest and React Testing Library for unit tests

Files:

  • components/drawer/__tests__/Drawer.test.tsx
🧠 Learnings (5)
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to **/__tests__/**/*.test.{ts,tsx} : Write comprehensive tests using Jest and React Testing Library

Applied to files:

  • components/drawer/__tests__/Drawer.test.tsx
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Place tests in `__tests__` directory as `index.test.tsx` or `componentName.test.tsx`

Applied to files:

  • components/drawer/__tests__/Drawer.test.tsx
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to **/__tests__/**/*.test.{ts,tsx} : Use snapshot testing for UI components

Applied to files:

  • components/drawer/__tests__/Drawer.test.tsx
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to **/__tests__/**/*.test.{ts,tsx} : Include snapshot tests for UI components

Applied to files:

  • components/drawer/__tests__/Drawer.test.tsx
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/*.{ts,tsx} : Achieve 100% test coverage

Applied to files:

  • components/drawer/__tests__/Drawer.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: test lib/es module (es, 2/2)
  • GitHub Check: test lib/es module (es, 1/2)
  • GitHub Check: build
  • GitHub Check: test-node
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: test-react-legacy (18, 2/2)
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: lint
  • GitHub Check: test-react-legacy (18, 1/2)
  • GitHub Check: build preview
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: visual-diff snapshot (1/2)
  • GitHub Check: size
  • GitHub Check: build
🔇 Additional comments (2)
components/drawer/DrawerPanel.tsx (1)

84-88: 合并 closable 与上下文配置、计算 placement 的实现是合理且健壮的

  • Line 99 使用 closable ?? contextClosable,保证组件 props 优先于 ConfigProvider 配置,且不会把 false 误当作“未配置”,符合预期优先级语义。
  • Line 100 单独处理 false,使 closablePlacementundefined 时不再渲染关闭按钮,逻辑上与 mergedClosable 一致。
  • Line 103 通过 typeof mergedClosableVal === 'object' && mergedClosableVal 避免了 null 情况下读取 placement 抛错的问题,空值安全性到位。
  • 组合下来,默认场景会落到 'start'placement: 'end' 时才增加 -close-end 类并把按钮渲染到尾部,行为与下方 header 中的左右渲染逻辑一致。

整体实现清晰且类型安全,目前不建议额外修改。

Also applies to: 98-107

components/drawer/__tests__/Drawer.test.tsx (1)

506-528: it.each 覆盖 mask blur 组合场景较全面,逻辑正确

  • 使用 testCases 枚举多种 mask / contextMask / 期望 blur / mask 是否打开的组合,避免重复样板代码。
  • 分支里先根据 openMask 判断是否应存在 mask,再断言是否包含 ant-drawer-mask-blur,能较好反映业务规则。

该段测试目前看起来是正确且易维护的。

@codecov
Copy link

codecov bot commented Nov 28, 2025

Bundle Report

Changes will increase total bundle size by 142 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
antd.min-array-push 3.86MB 142 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: antd.min-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
antd-with-locales.min.js 71 bytes 2.12MB 0.0%
antd.min.js 71 bytes 1.74MB 0.0%

@Pareder
Copy link
Contributor

Pareder commented Dec 3, 2025

@meet-student What is left to do for this PR to be merged?

@meet-student meet-student requested a review from zombieJ December 3, 2025 09:10
@meet-student
Copy link
Member Author

@zombieJ cc

@Pareder
Copy link
Contributor

Pareder commented Dec 3, 2025

@meet-student As I see closable prop should also be added to ConfigProvider documentation https://ant.design/components/config-provider#component-config.

@meet-student
Copy link
Member Author

@meet-student As I see closable prop should also be added to ConfigProvider documentation ant.design/components/config-provider#component-config.

ok await.

thinks

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c8720b and cd3a7de.

📒 Files selected for processing (2)
  • components/config-provider/index.en-US.md (1 hunks)
  • components/config-provider/index.zh-CN.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
components/*/*.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

components/*/*.md: Provide both English and Chinese documentation
When documenting component APIs, use table structure with string defaults in backticks, boolean defaults as literal values, number defaults as literal values, no default value as -, descriptions starting with capital letter without ending period, properties sorted alphabetically

Files:

  • components/config-provider/index.zh-CN.md
  • components/config-provider/index.en-US.md
**/*.{ts,tsx,md}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use 2-space indentation

Files:

  • components/config-provider/index.zh-CN.md
  • components/config-provider/index.en-US.md
components/**/*.md

📄 CodeRabbit inference engine (AGENTS.md)

components/**/*.md: Markdown documentation should have Chinese headings with manual English anchor IDs in format: ## 中文标题 {#english-anchor-id}
New properties should declare the version number they become available in documentation

Files:

  • components/config-provider/index.zh-CN.md
  • components/config-provider/index.en-US.md
**/*.md

📄 CodeRabbit inference engine (AGENTS.md)

**/*.md: Anchor IDs must match regex ^[a-zA-Z][\w-:\.]*$ and not exceed 32 characters (except for demo IDs containing -demo-)
FAQ section headings should have anchor IDs prefixed with faq-
Same topics in Chinese and English documentation should use identical anchor IDs
Provide both Chinese and English versions for documentation

Files:

  • components/config-provider/index.zh-CN.md
  • components/config-provider/index.en-US.md
🧠 Learnings (4)
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Applies to components/**/demo/*.tsx : Demo code import order: React → dependencies → antd components → custom components → types → styles

Applied to files:

  • components/config-provider/index.zh-CN.md
  • components/config-provider/index.en-US.md
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/**/*.tsx : Use camelCase for props with specific patterns: `default` + `PropName` for defaults, `forceRender` for force rendering, `open` instead of `visible` for panel state, `show` + `PropName` for display toggles, `PropName` + `able` for capabilities, `dataSource` for data source, `disabled` for disabled state, `extra` for additional content, `icon` for icons, `trigger` for triggers, `className` for CSS classes

Applied to files:

  • components/config-provider/index.zh-CN.md
  • components/config-provider/index.en-US.md
📚 Learning: 2025-11-24T16:30:28.374Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-24T16:30:28.374Z
Learning: Applies to components/**/*.{ts,tsx} : Never hardcode colors, sizes, or spacing values

Applied to files:

  • components/config-provider/index.zh-CN.md
📚 Learning: 2025-11-24T16:31:15.831Z
Learnt from: CR
Repo: ant-design/ant-design PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-24T16:31:15.831Z
Learning: Support React 16 ~ 19 versions

Applied to files:

  • components/config-provider/index.en-US.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: test-react-latest-dist (dist-min, 1/2)
  • GitHub Check: test-react-latest-dist (dist-min, 2/2)
  • GitHub Check: test-react-latest-dist (dist, 2/2)
  • GitHub Check: test-react-latest-dist (dist, 1/2)
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: test-react-legacy (18, 1/2)
  • GitHub Check: test-react-legacy (18, 2/2)
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: visual-diff snapshot (1/2)
🔇 Additional comments (1)
components/config-provider/index.zh-CN.md (1)

132-132: Remove closable property from ConfigProvider drawer configuration; it is not supported.

Based on Ant Design documentation, ConfigProvider does not support globally setting Drawer.closable — the closable prop must be set per Drawer component instance, not through ConfigProvider. The entry on line 132 including closable?: [DrawerProps\["closable"\]](/components/drawer-cn#api) should be removed entirely, as this property is not a valid ConfigProvider drawer configuration option.

Likely an incorrect or invalid review comment.

@codecov
Copy link

codecov bot commented Dec 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (56c7c9f) to head (92e5cef).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #55985   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          804       804           
  Lines        14838     14843    +5     
  Branches      3919      3922    +3     
=========================================
+ Hits         14838     14843    +5     

☔ 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 Dec 9, 2025
@meet-student meet-student merged commit 0c293a7 into ant-design:master Dec 9, 2025
37 of 38 checks passed
@afc163 afc163 mentioned this pull request Dec 15, 2025
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.

Drawer: closable placement config in ConfigProvider doesn't work

5 participants