Skip to content

refactor(layout): declare mix layout on ProLayoutProps only#9600

Merged
chenshuai2144 merged 1 commit intomasterfrom
cursor/layout-mix-on-props-only-63cf
Apr 23, 2026
Merged

refactor(layout): declare mix layout on ProLayoutProps only#9600
chenshuai2144 merged 1 commit intomasterfrom
cursor/layout-mix-on-props-only-63cf

Conversation

@chenshuai2144
Copy link
Copy Markdown
Contributor

@chenshuai2144 chenshuai2144 commented Apr 22, 2026

Summary

PureSettings.layout in defaultSettings is again only 'side' | 'top'. The deprecated root value layout="mix" is typed on ProLayout via ProLayoutLayoutMode on ProLayoutProps (Omit<GlobalTypes, 'layout'> so it does not widen SiderMenuProps / BaseMenuProps).

Runtime: mix is normalized to side when passing layout into Header and SiderMenu, and when invoking menuRender (new ProLayoutMenuRenderCallbackProps + toMenuRenderCallbackProps so the callback receives HeaderViewProps-compatible props).

Exports

  • ProLayoutLayoutMode
  • ProLayoutMenuRenderCallbackProps (from src/layout/index.tsx)

Verification

  • pnpm run tsc
  • pnpm exec vitest run tests/layout/index.test.tsx

Submitted by Cursor

Open in Web Open in Cursor 

Summary by CodeRabbit

发布说明

  • 改进
    • 优化了布局配置系统,简化了可用的布局选项。已移除对特定已弃用布局模式的支持,现仅保留更稳定高效的布局方案。

- Keep PureSettings.layout as side | top only
- Declare ProLayoutLayoutMode on ProLayout root props (includes mix)
- Normalize mix to side for Header, SiderMenu, and menuRender callback
- Export ProLayoutMenuRenderCallbackProps for menuRender typings

Co-authored-by: 陈帅 <wasd2144@hotmail.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c7514cf7-3271-4853-b6ef-062e2c4d51c7

📥 Commits

Reviewing files that changed from the base of the PR and between fcc0c2d and d98d4fc.

📒 Files selected for processing (3)
  • src/layout/ProLayout.tsx
  • src/layout/defaultSettings.ts
  • src/layout/index.tsx

📝 Walkthrough

Walkthrough

ProLayout 的类型系统进行了重构,通过移除混合布局('mix')选项并引入标准化工具来规范化布局设置。移除了继承的 layout 属性,重新引入具有弃用标记的 layout 属性,并确保相关组件接收到规范化后的布局值。

Changes

Cohort / File(s) Summary
ProLayout 类型与规范化
src/layout/ProLayout.tsx
更新 ProLayoutProps 类型定义,移除继承的 layout 并引入包含 'mix' 弃用标记的新 layout 属性。新增 ProLayoutLayoutModeProLayoutMenuRenderCallbackProps 导出类型。添加 menuLayoutForPureSettingstoMenuRenderCallbackProps 规范化工具,确保 HeaderSiderMenu 组件接收规范化后的布局值(将 'mix'undefined 转换为 'side')。
默认设置更新
src/layout/defaultSettings.ts
PureSettings.layout 类型中移除 'mix' 布局选项,仅保留 'side''top'。删除了关于历史 'mix' 行为的文档说明。
类型导出扩展
src/layout/index.tsx
在模块的 export type 块中新增两个导出类型:ProLayoutLayoutModeProLayoutMenuRenderCallbackProps

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 混合布局已褪去,
规范化工具来护航,
类型更新显风采,
属性流转却如常,
兔兔为你梳理清! ✨

✨ 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 cursor/layout-mix-on-props-only-63cf

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
Copy Markdown
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 refactors the layout mode handling in ProLayout by deprecating the 'mix' layout and introducing a normalization helper to treat it as 'side' at runtime. It also introduces new types for menu rendering callbacks to ensure consistent layout values. A suggestion was made to refine the ProLayoutMenuRenderCallbackProps type by making the layout property required, as it is always normalized before being passed to the callback.

Comment thread src/layout/ProLayout.tsx
Comment on lines +87 to +89
export type ProLayoutMenuRenderCallbackProps = Omit<ProLayoutProps, 'layout'> & {
layout?: NonNullable<ProSettings['layout']>;
};
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

The layout property in ProLayoutMenuRenderCallbackProps is marked as optional, but the toMenuRenderCallbackProps helper function always provides a normalized value (either 'side' or 'top'). Making this property required would provide more accurate type information for users implementing the menuRender callback, ensuring they know the layout is always defined and normalized at that point.

Suggested change
export type ProLayoutMenuRenderCallbackProps = Omit<ProLayoutProps, 'layout'> & {
layout?: NonNullable<ProSettings['layout']>;
};
export type ProLayoutMenuRenderCallbackProps = Omit<ProLayoutProps, 'layout'> & {
layout: NonNullable<ProSettings['layout']>;
};

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.72%. Comparing base (fcc0c2d) to head (d98d4fc).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/layout/ProLayout.tsx 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9600      +/-   ##
==========================================
- Coverage   88.77%   88.72%   -0.05%     
==========================================
  Files         360      360              
  Lines       11159    11161       +2     
  Branches     4133     4131       -2     
==========================================
- Hits         9906     9903       -3     
- Misses       1104     1108       +4     
- Partials      149      150       +1     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chenshuai2144 chenshuai2144 marked this pull request as ready for review April 23, 2026 10:20
Copilot AI review requested due to automatic review settings April 23, 2026 10:20
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Apr 23, 2026
@chenshuai2144 chenshuai2144 merged commit bdbf841 into master Apr 23, 2026
10 of 12 checks passed
@chenshuai2144 chenshuai2144 deleted the cursor/layout-mix-on-props-only-63cf branch April 23, 2026 10:20
@dosubot dosubot Bot added the layout label Apr 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors layout typing to keep legacy layout="mix" support only at the ProLayout root prop level while keeping internal settings/components (PureSettings, Header, SiderMenu) typed as 'side' | 'top', with runtime normalization of mix -> side.

Changes:

  • Narrow PureSettings.layout back to 'side' | 'top' and remove mix from its docs/type.
  • Introduce ProLayoutLayoutMode ('side' | 'top' | 'mix') on ProLayoutProps.layout, and normalize mix/undefined to 'side' when passing layout to Header, SiderMenu, and menuRender.
  • Export ProLayoutLayoutMode and ProLayoutMenuRenderCallbackProps from src/layout/index.tsx.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/layout/index.tsx Re-exports new public types from ProLayout for external consumers.
src/layout/defaultSettings.ts Narrows PureSettings.layout to `'side'
src/layout/ProLayout.tsx Adds legacy-aware root layout type + normalization helper; applies normalized layout when rendering header/sider and invoking menuRender.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/layout/ProLayout.tsx
export type ProLayoutProps = Omit<GlobalTypes, 'layout'> & {
/**
* @name layout 的布局方式(根组件)
* @deprecated `layout="mix"` 仍会被接受,运行时按 `side` 处理
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

The @deprecated tag on ProLayoutProps.layout will mark the entire layout prop as deprecated (including valid 'side' | 'top' usages) in TS tooling. If the intent is only to deprecate the 'mix' value, move the deprecation marker to the union member (e.g. deprecate 'mix' specifically) and keep the prop itself non-deprecated, or replace @deprecated with a descriptive note without the tag.

Suggested change
* @deprecated `layout="mix"` 仍会被接受,运行时按 `side` 处理
* 注意:`layout="mix"` 仍会被接受,运行时按 `side` 处理

Copilot uses AI. Check for mistakes.
Comment thread src/layout/ProLayout.tsx
): NonNullable<ProSettings['layout']> =>
layout === 'mix' || layout === undefined ? 'side' : layout;

/** `menuRender` 回调首参:与 Header 一致,不含历史 `mix` */
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

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

The doc comment for ProLayoutMenuRenderCallbackProps says it's "与 Header 一致", but the type is based on ProLayoutProps (minus layout) and therefore includes many props that HeaderViewProps doesn't. Consider rewording to clarify that this type only guarantees the layout field matches HeaderViewProps (i.e., no legacy mix), rather than implying the whole shape is identical.

Suggested change
/** `menuRender` 回调首参:与 Header 一致,不含历史 `mix` */
/**
* `menuRender` 回调首参:基于 `ProLayoutProps`,但其 `layout` 字段与 Header 保持一致,
* 不含历史 `mix`
*/

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

layout size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants