Skip to content

Conversation

KouSum
Copy link
Contributor

@KouSum KouSum commented Sep 11, 2025

🤔 这个变动的性质是?

  • 新特性提交
  • 日常 bug 修复
  • 站点、文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • TypeScript 定义更新
  • 包体积优化
  • 性能优化
  • 功能增强
  • 国际化改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他改动(是关于什么的改动?)

🔗 相关 Issue

💡 需求背景和解决方案

兼容nextjs ssr,Col组件的class初始状态为class=""元素会闪一下

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • fork仓库代码是否为最新避免文件冲突
  • Files changed 没有 package.json lock 等无关文件

Summary by CodeRabbit

  • 重构
    • 初始化列组件的类名与样式基于当前属性即时计算,避免首次渲染的额外更新。
    • 依赖变更时改用更新器方式刷新类名与样式,确保栅格布局与间距准确同步。
    • 影响:初始加载更流畅、渲染更一致;对外用法不变。

Copy link

coderabbitai bot commented Sep 11, 2025

Walkthrough

src/packages/col/col.tsx 中,将组件内部状态的初始值由占位值改为基于当前 props 的计算值;useEffect 依旧在 span/offset/gutter 变化时更新,但改为使用函数式更新以复用计算函数。对外 API 未变化。

Changes

Cohort / File(s) Summary of Changes
Col 组件初始化与更新逻辑
src/packages/col/col.tsx
colNamecolStyle 的初始状态改为调用 classs()getStyle() 的计算结果;useEffect 在依赖变更时使用 updater 风格调用 setColName(classs)setColStyle(getStyle);无导出签名修改。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

我在栅格间跳一跳,耳朵量了 span 的妙,
偏移 offset 轻轻靠,gutter 随风把路扫。
初始即准不再绕,函数更新更贴靠,
小兔点头把仓告:列名样式都报到。 🐇✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.

Pre-merge checks (2 passed, 1 warning)

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning PR 描述已选择“日常 bug 修复”并完成自检列表,但关键模板项不完整:未提供“相关 Issue”链接,“需求背景和解决方案”仅为一句话说明且缺少具体实现细节(修改了哪些文件、如何修复、是否添加测试或提供视觉对比),因此目前无法充分评估变更的风险与回归范围。按仓库模板需要补充这些信息以便审阅与合并决策。 请补充相关 Issue 链接(若有),并在“需求背景和解决方案”中详细说明根因与修复方法;列出主要修改文件(例如 src/packages/col/col.tsx)并简述关键代码改动(如使用 classs() 和 getStyle 在初始化时避免空 class),说明是否新增或更新测试;最后上传修复前后的截图或 GIF 以确认视觉回归,并在描述末尾补充影响范围与回归风险评估。
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Title Check ✅ Passed 标题清晰且与变更主旨一致:说明这是一个修复(fix),并具体指出为兼容 Next.js SSR 解决初始 class="" 导致的元素闪烁问题,语义明确且无冗余信息,便于审阅历史记录检索。
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 github-actions bot added action:review This PR needs more reviews (less than 2 approvals) 3.x Target branch 3.x labels Sep 11, 2025
@KouSum KouSum changed the title fix: 兼容nextjs ssr,初始状态class=""元素会闪一下 fix: 兼容nextjs ssr,Col组件初始状态class=""元素会闪一下 Sep 11, 2025
Copy link

@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)
src/packages/col/col.tsx (1)

52-55: 依赖列表缺失 isFirst/isLast,可能导致左右内边距未更新

getStyle 依赖 isFirst/isLast,但 effect 依赖中未包含,Row 改变首末列时可能不会触发更新。

-  }, [span, offset, gutter])
+  }, [span, offset, gutter, isFirst, isLast])
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52d84bd and bf1fc2d.

📒 Files selected for processing (1)
  • src/packages/col/col.tsx (1 hunks)
🔇 Additional comments (2)
src/packages/col/col.tsx (2)

50-51: SSR 首帧计算初值已对齐 props,能避免 Next.js 下的闪烁 — LGTM

通过在 useState 中用 classs()/getStyle() 的计算初值,首屏即可得到稳定 class/style,方向正确。


13-20: 修复:将 gutter 默认值从字符串 '0' 改为数字 0,并按数值判断以避免 SSR/CSR 不一致

defaultProps.gutter 当前为字符串 '0'(truthy),会在 gutter === '0' 时仍添加 gutter 类,导致类名与样式不一致并可能产生 SSR/CSR 或视觉偏差。

@@
-  gutter: '0',
+  gutter: 0,
@@
-    return `${prefixCls} ${prefixCls}-${span} ${
-      gutter ? `${prefixCls}-gutter` : ''
-    } ${prefixCls}-offset-${offset}`
+    return `${prefixCls} ${prefixCls}-${span} ${
+      Number(gutter) > 0 ? `${prefixCls}-gutter` : ''
+    } ${prefixCls}-offset-${offset}`
@@
-    const style: CSSProperties = {}
-    if (!isFirst) {
-      style.paddingLeft = `${(gutter as number) / 2}px`
-    }
-    if (!isLast) {
-      style.paddingRight = `${(gutter as number) / 2}px`
-    }
+    const style: CSSProperties = {}
+    const g = Number(gutter) || 0
+    if (!isFirst) {
+      style.paddingLeft = `${g / 2}px`
+    }
+    if (!isLast) {
+      style.paddingRight = `${g / 2}px`
+    }

文件:src/packages/col/col.tsx(行 13-20;相关代码块也在 32-38、39-49)。确认 WebColProps.gutter 的类型为 number;若不是,更新类型或在组件中使用 Number(gutter) || 0 做兼容处理。可在仓库根目录运行以下命令验证类型(不要指定 --type):

rg -nP -C2 '(export\s+)?(interface|type)\s+WebColProps\b'
rg -nP -C2 '\bWebColProps\b|gutter\s*:'

Copy link

codecov bot commented Sep 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.15%. Comparing base (52d84bd) to head (bf1fc2d).
⚠️ Report is 1 commits behind head on feat_v3.x.

Additional details and impacted files
@@            Coverage Diff             @@
##           feat_v3.x    #3358   +/-   ##
==========================================
  Coverage      88.15%   88.15%           
==========================================
  Files            291      291           
  Lines          19212    19212           
  Branches        2988     2988           
==========================================
  Hits           16937    16937           
  Misses          2269     2269           
  Partials           6        6           

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

@xiaoyatong xiaoyatong merged commit 7802a1e into jdf2e:feat_v3.x Sep 22, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Target branch 3.x action:review This PR needs more reviews (less than 2 approvals) size/XS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants