Skip to content

refactor: update component renders from antd#28

Merged
zombieJ merged 3 commits into
masterfrom
update-component-renders
Mar 10, 2026
Merged

refactor: update component renders from antd#28
zombieJ merged 3 commits into
masterfrom
update-component-renders

Conversation

@zombieJ

@zombieJ zombieJ commented Mar 10, 2026

Copy link
Copy Markdown
Member

Summary

  • Enhance Layout render with all sub-components (Header, Sider, Content, Footer)
  • Add Input.Password to Input render
  • Add Input.Group with nested Inputs
  • Move Space.Addon inside Space.Compact with content
  • Add default Modal._InternalPanelDoNotUseOrYouWillBeFired
  • Simplify Cascader and Layout render functions

Test plan

  • Verify styles are extracted correctly for updated components
  • Run existing tests to ensure no regressions

🤖 Generated with Claude Code

Summary by CodeRabbit

发布说明

  • 重构
    • 优化了级联选择器、输入组件和页面布局的渲染逻辑,统一了多种输入表现(如组合、搜索、文本域、密码等)的呈现方式。
    • 调整了模态框与间距组件的组合呈现,改善了组件间的布局一致性。
  • 测试
    • 新增并扩展了若干测试用例与预期警告白名单,提升了 SSR 与样式提取相关的稳定性。

- Enhance Layout render with all sub-components (Header, Sider, Content, Footer)
- Add Input.Password to Input render
- Add Input.Group with nested Inputs
- Move Space.Addon inside Space.Compact with content
- Add default Modal._InternalPanelDoNotUseOrYouWillBeFired
- Simplify Cascader and Layout render functions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 10, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@zombieJ has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 18 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e8282b34-f914-4ae4-97cb-d37cec7a9991

📥 Commits

Reviewing files that changed from the base of the PR and between bbf7677 and 87fd7b8.

📒 Files selected for processing (1)
  • src/index.tsx
📝 Walkthrough

Walkthrough

src/index.tsx 中重构并扩展了 ComponentCustomizeRender 的渲染分支:新增或改写了对 Cascader、Space、Input、Modal 和 Layout 的自定义渲染分支;同时对导出/签名做了相应调整。测试文件增加/调整了若干断言与允许的警告列表。

Changes

Cohort / File(s) Summary
渲染逻辑主变更
src/index.tsx
重构 ComponentCustomizeRender 分支:新增 Cascader(包含 Panel 分支)、扩展 Space 渲染以在 Compact 内使用 Addon+Button、加入 Input 的多态渲染(group、Search、TextArea、Password、OTP)、Modal 增加隐藏/Internal Panel 节点,合并并替换为完整的 Layout 结构(Header、Sider、Content、Footer);更新了 Cascader、Layout、Input 对应的方法签名。
单元测试更新
tests/index.test.tsx
新增测试用例(提取 Modal.confirm 并断言 .ant-modal-confirm-title 存在);对若干测试对象字面量添加尾随逗号并标准化测试块结尾。
SSR 测试允许警告更新
tests/ssr.test.tsx
扩展 allowedWarnings 列表以包含对 Input.Group 的弃用警告,调整了格式化(尾随逗号)。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

诗意庆祝

🐰 我在代码地里轻轻跳,

斑斓分支开又绕,
Cascader 和 Input 在月光跑,
Layout 摆好四方道,
小兔拍掌,更新就到! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题「refactor: update component renders from antd」准确总结了主要变更内容,即重构并更新了多个Ant Design组件的渲染方式。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-component-renders

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.

zombieJ and others added 2 commits March 10, 2026 16:50
- Add test for Modal.confirm style extraction
- Add Input.Group deprecation warning to allowed list
- Fix minor formatting issues (trailing commas, semicolons)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add explicit types for component render functions (typeof antd.XXX)
- Optimize import statements structure
- Apply consistent code formatting

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/index.test.tsx (1)

83-86: Modal.confirm 用例只覆盖 Modal 分支。

现在这里调用 extractStyle() 会把整套组件都渲染一遍,这个断言更像是全量烟测,回归定位也会更模糊。建议收窄到 includes: ['Modal'],让它直接验证这次新增的 Modal 渲染逻辑。

可选修改
   it('should extract Modal.confirm', () => {
-    const cssText = extractStyle();
+    const cssText = extractStyle({
+      includes: ['Modal'],
+    });
     expect(cssText).toContain('.ant-modal-confirm-title');
   });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/index.test.tsx` around lines 83 - 86, The test "should extract
Modal.confirm" currently calls extractStyle() without scoping and renders all
components; update the call to extractStyle({ includes: ['Modal'] }) so the run
only covers the Modal branch and verifies Modal.confirm-specific output (keep
the expect(cssText).toContain('.ant-modal-confirm-title') assertion). Locate the
call to extractStyle in the test and replace it with the scoped options form to
limit rendering to the Modal component.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/index.test.tsx`:
- Around line 83-86: The test "should extract Modal.confirm" currently calls
extractStyle() without scoping and renders all components; update the call to
extractStyle({ includes: ['Modal'] }) so the run only covers the Modal branch
and verifies Modal.confirm-specific output (keep the
expect(cssText).toContain('.ant-modal-confirm-title') assertion). Locate the
call to extractStyle in the test and replace it with the scoped options form to
limit rendering to the Modal component.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 369db342-6ecf-405d-afe4-19e62345d787

📥 Commits

Reviewing files that changed from the base of the PR and between 65e319a and bbf7677.

📒 Files selected for processing (2)
  • tests/index.test.tsx
  • tests/ssr.test.tsx

@zombieJ zombieJ merged commit 463be01 into master Mar 10, 2026
7 of 8 checks passed
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, 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 refactors the component rendering logic within the static style extraction utility for Ant Design. The primary goal is to ensure that a wider range of Ant Design components and their sub-components, including various Input types, Layout sections, Space.Compact with Addon, and Modal internal panels, are correctly rendered and their styles are extracted. This enhancement improves the robustness of server-side rendering (SSR) and static style generation by covering more component variations and simplifying existing render functions.

Highlights

  • Layout Component: Enhanced the Layout component's rendering to include all its sub-components: Header, Sider, Content, and Footer.
  • Input Component: Expanded the Input component's rendering to cover Input.Password, Input.Group with nested inputs, Input.Search, Input.TextArea, and Input.OTP.
  • Space Component: Refactored the Space component's rendering to move Space.Addon inside Space.Compact for better representation.
  • Modal Component: Added Modal._InternalPanelDoNotUseOrYouWillBeFired to the default Modal rendering for comprehensive style extraction.
  • Cascader Component: Simplified the Cascader component's rendering to include both Cascader and Cascader.Panel.
  • Code Simplification: Streamlined render functions for Cascader and Layout by consolidating their definitions.

🧠 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.

Changelog
  • src/index.tsx
    • Reorganized imports for @ant-design/cssinjs for better readability.
    • Added comprehensive rendering for Cascader and Cascader.Panel.
    • Updated Space component rendering to include Space.Addon within Space.Compact.
    • Introduced full rendering support for Input component variations, including Input.Group, Input.Search, Input.TextArea, Input.Password, and Input.OTP.
    • Included Modal._InternalPanelDoNotUseOrYouWillBeFired in the Modal component's rendering.
    • Expanded Layout component rendering to encompass Layout.Header, Layout.Sider, Layout.Content, and Layout.Footer.
    • Removed redundant Cascader and Input render definitions, consolidating them into the new comprehensive definitions.
    • Applied minor formatting adjustments to code.
  • tests/index.test.tsx
    • Corrected a missing comma in a test configuration object.
    • Added a new test case to verify the extraction of Modal.confirm styles.
  • tests/ssr.test.tsx
    • Updated the allowedWarnings list to include a deprecation warning for Input.Group, preventing false positives during SSR tests.
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.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

The code changes add renderers for Cascader, Input, and Layout components, and modify the existing Space renderer. The reviewer suggests that the Cascader and Layout renderers should accept the component as a parameter for consistency, and that the Cascader component should include the options prop to prevent runtime errors. The reviewer also suggests that the Space and Input and Modal renderers should be typed with a specific type instead of 'any' for better type safety and consistency.

Comment thread src/index.tsx
Comment on lines 22 to +27
BackTop: () => <antd.FloatButton.BackTop />,
Cascader: (Cascader: typeof antd.Cascader) => (
<>
<Cascader />
<Cascader.Panel />
</>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

For consistency with other component renderers in this file, the Cascader renderer should accept the component as a parameter instead of hardcoding antd.Cascader. The defaultNode function is designed to pass the component to this renderer. Additionally, the Cascader and Cascader.Panel components require an options prop, which is missing and could cause runtime warnings or errors.

Suggested change
BackTop: () => <antd.FloatButton.BackTop />,
Cascader: (Cascader: typeof antd.Cascader) => (
<>
<Cascader />
<Cascader.Panel />
</>
Cascader: (Cascader: typeof antd.Cascader) => (
<>
<Cascader options={[]} />
<Cascader.Panel options={[]} />
</>
),

Comment thread src/index.tsx
Comment on lines 48 to 56
),
Space: (Space: any) => (
Space: (Space: typeof antd.Space) => (
<>
<Space />
<Space.Addon />
<Space.Compact>
<antd.Button />
<Space.Addon>1</Space.Addon>
</Space.Compact>
</>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The Space renderer hardcodes antd.Space.Addon instead of using the Addon from the passed Space component. Also, the Space parameter is typed as any. For consistency and type safety, it should use the passed component and have a specific type.

Suggested change
),
Space: (Space: any) => (
Space: (Space: typeof antd.Space) => (
<>
<Space />
<Space.Addon />
<Space.Compact>
<antd.Button />
<Space.Addon>1</Space.Addon>
</Space.Compact>
</>
Space: (Space: typeof antd.Space) => (
<>
<Space />
<Space.Compact>
<antd.Button />
<Space.Addon>1</Space.Addon>
</Space.Compact>
</>
),

Comment thread src/index.tsx
Comment on lines 57 to +69
),
Modal: (Modal: any) => (
Input: (Input: typeof antd.Input) => (
<>
<Input />
<Input.Group>
<Input />
<Input />
</Input.Group>
<Input.Search />
<Input.TextArea />
<Input.Password />
<Input.OTP />
</>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The Input parameter is typed as any. For better type safety and consistency with how components were previously typed, it's better to use a specific type like typeof antd.Input.

Suggested change
),
Modal: (Modal: any) => (
Input: (Input: typeof antd.Input) => (
<>
<Input />
<Input.Group>
<Input />
<Input />
</Input.Group>
<Input.Search />
<Input.TextArea />
<Input.Password />
<Input.OTP />
</>
Input: (Input: typeof antd.Input) => (
<>
<Input />
<Input.Group>
<Input />
<Input />
</Input.Group>
<Input.Search />
<Input.TextArea />
<Input.Password />
<Input.OTP />
</>
),

Comment thread src/index.tsx
Comment on lines +70 to 76
),
Modal: (Modal: typeof antd.Modal) => (
<>
<Modal />
<Modal._InternalPanelDoNotUseOrYouWillBeFired />
<Modal._InternalPanelDoNotUseOrYouWillBeFired type="confirm" />
</>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The Modal parameter is typed as any. For better type safety and consistency, it's better to use a specific type like typeof antd.Modal.

Suggested change
),
Modal: (Modal: typeof antd.Modal) => (
<>
<Modal />
<Modal._InternalPanelDoNotUseOrYouWillBeFired />
<Modal._InternalPanelDoNotUseOrYouWillBeFired type="confirm" />
</>
Modal: (Modal: typeof antd.Modal) => (
<>
<Modal />
<Modal._InternalPanelDoNotUseOrYouWillBeFired />
<Modal._InternalPanelDoNotUseOrYouWillBeFired type="confirm" />
</>
),

Comment thread src/index.tsx
Comment on lines 85 to +92
},
Layout: (Layout: typeof antd.Layout) => (
<>
<Layout />
<Layout.Sider />
</>
),
Cascader: (Cascader: typeof antd.Cascader) => (
<>
<Cascader options={[]} />
<Cascader.Panel options={[]} />
</>
),
Input: (Input: typeof antd.Input) => (
<>
<Input />
<Input.OTP />
<Input.Search />
<Input.TextArea />
</>
<Layout>
<Layout.Header>Header</Layout.Header>
<Layout.Sider>Sider</Layout.Sider>
<Layout.Content>Content</Layout.Content>
<Layout.Footer>Footer</Layout.Footer>
</Layout>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

For consistency with other component renderers, the Layout renderer should accept the component as a parameter. The current implementation ignores the component passed by defaultNode and hardcodes antd.Layout. Using the passed parameter makes the code more robust and consistent.

Suggested change
},
Layout: (Layout: typeof antd.Layout) => (
<>
<Layout />
<Layout.Sider />
</>
),
Cascader: (Cascader: typeof antd.Cascader) => (
<>
<Cascader options={[]} />
<Cascader.Panel options={[]} />
</>
),
Input: (Input: typeof antd.Input) => (
<>
<Input />
<Input.OTP />
<Input.Search />
<Input.TextArea />
</>
<Layout>
<Layout.Header>Header</Layout.Header>
<Layout.Sider>Sider</Layout.Sider>
<Layout.Content>Content</Layout.Content>
<Layout.Footer>Footer</Layout.Footer>
</Layout>
Layout: (Layout: typeof antd.Layout) => (
<Layout>
<Layout.Header>Header</Layout.Header>
<Layout.Sider>Sider</Layout.Sider>
<Layout.Content>Content</Layout.Content>
<Layout.Footer>Footer</Layout.Footer>
</Layout>
),

@zombieJ zombieJ deleted the update-component-renders branch March 10, 2026 09:26
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