Skip to content

fix: allow zero flex#55829

Merged
li-jia-nan merged 1 commit intomasterfrom
fix-isNonNullable-f-23
Nov 23, 2025
Merged

fix: allow zero flex#55829
li-jia-nan merged 1 commit intomasterfrom
fix-isNonNullable-f-23

Conversation

@li-jia-nan
Copy link
Member

中文版模板 / 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 允许 flex 赋值为 0
🇨🇳 Chinese 允许 flex 赋值为 0

@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 23, 2025

👁 Visual Regression Report for PR #55829 Passed ✅

🎯 Target branch: master (6b79b3a)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎

🎊 Congrats! No visual-regression diff found.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 23, 2025

Preview is ready

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @li-jia-nan, 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 addresses a bug in the Flex component where a flex value of 0 was not being correctly applied due to a falsy check. By updating the conditional logic, the component now properly recognizes and sets flex: 0, enhancing the precision and flexibility of layout control for users.

Highlights

  • Bug Fix: Resolved an issue where the flex property in the Flex component would not correctly apply a value of 0.
  • Conditional Logic Update: Modified the conditional check for applying the flex style from if (flex) to if (isNonNullable(flex)) to ensure 0 is treated as a valid value.
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 23, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • 修复了弹性布局组件对数值的处理逻辑。现在包括 0 在内的有效数值会被正确应用作为弹性值,之前这些值会被错误地忽略。

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

概述

修改了 components/flex/index.tsx 中flex样式赋值的条件判断方式,将真值检查更改为非空值检查,使得0等假值能够作为有效的flex值应用。

改动

功能/文件 改动说明
flex组件条件判断修复
components/flex/index.tsx
将flex属性的条件检查从真值判断(if (flex))改为非空判断(if (flex != null)),允许0等假值作为有效的flex值应用到mergedStyle中

代码审查工作量评估

🎯 1 (简单) | ⏱️ ~5 分钟

需要关注的地方:

  • 验证此改动不会对现有使用0作为flex值的组件产生副作用
  • 确认是否需要更新相关单元测试以覆盖flex为0的场景

可能相关的PR

  • fix: allow zero gap #55803:同样修改了 components/flex/index.tsx 中的空值检查逻辑,以支持零值(该PR针对gap属性,本PR针对flex属性)

建议标签

lgtm

小诗

🐰 flex为零不再隐,
条件改写显真心,
假值如今皆生效,
小小改动大不同!✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed 拉取请求标题清晰简洁地总结了主要变更:允许 flex 属性接受 0 值,与代码摘要中的更改内容完全吻合。
Description check ✅ Passed 拉取请求描述虽然主要是标准模板,但已明确标注为 Bug 修复,且提供了变更日志条目说明允许 flex 赋值为 0,与实际代码变更内容相关。
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
  • Commit unit tests in branch fix-isNonNullable-f-23

📜 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 6b79b3a and 88624c0.

📒 Files selected for processing (1)
  • components/flex/index.tsx (1 hunks)
⏰ 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). (16)
  • GitHub Check: visual-diff snapshot (1/2)
  • GitHub Check: visual-diff snapshot (2/2)
  • GitHub Check: build
  • GitHub Check: test-react-latest (dom, 1/2)
  • GitHub Check: test-react-latest (dom, 2/2)
  • GitHub Check: test lib/es module (es, 1/2)
  • GitHub Check: test lib/es module (es, 2/2)
  • GitHub Check: build
  • GitHub Check: test-node
  • GitHub Check: test-react-legacy (18, 2/2)
  • GitHub Check: test-react-legacy (18, 1/2)
  • GitHub Check: lint
  • GitHub Check: build preview
  • GitHub Check: size
  • GitHub Check: Analyze (javascript)
  • GitHub Check: build
🔇 Additional comments (1)
components/flex/index.tsx (1)

58-60: 使用 isNonNullable(flex) 的修改实现了允许 flex = 0,且与 gap 逻辑保持一致

这里从简单的 truthy 判断改为 isNonNullable(flex),可以正确下发 flex={0} 等非 null/undefined 的值到 style.flex,解决原先 0 被误当成“未设置”而忽略的问题,同时与下方 gap 使用 isNonNullable(gap) 的写法保持一致,整体更统一清晰。props 上的 flex 只要显式提供(非 null/undefined)就覆盖 ctxFlex.style.flex,也符合常规优先级预期,看起来是安全且合理的行为。


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

The change in this pull request correctly addresses a bug where flex={0} was not being applied due to 0 being a falsy value. Using isNonNullable is a good, explicit way to check for null and undefined and is consistent with other parts of the codebase. I've left one comment suggesting the addition of a unit test to cover this case and prevent future regressions.

@coderabbitai coderabbitai bot added the lgtm This PR has been approved by a maintainer label Nov 23, 2025
@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
dist/antd.min.js 530.63 KB (+2 B 🔺)
dist/antd-with-locales.min.js 623.1 KB (+3 B 🔺)

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 23, 2025

@cloudflare-workers-and-pages
Copy link

Deploying ant-design-next with  Cloudflare Pages  Cloudflare Pages

Latest commit: 88624c0
Status: ✅  Deploy successful!
Preview URL: https://d49c509e.ant-design-next.pages.dev
Branch Preview URL: https://fix-isnonnullable-f-23.ant-design-next.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

Deploying ant-design with  Cloudflare Pages  Cloudflare Pages

Latest commit: 88624c0
Status: ✅  Deploy successful!
Preview URL: https://291b1b50.ant-design.pages.dev
Branch Preview URL: https://fix-isnonnullable-f-23.ant-design.pages.dev

View logs

@li-jia-nan li-jia-nan merged commit 4daf900 into master Nov 23, 2025
47 checks passed
@li-jia-nan li-jia-nan deleted the fix-isNonNullable-f-23 branch November 23, 2025 08:48
@codecov
Copy link

codecov bot commented Nov 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6b79b3a) to head (88624c0).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #55829   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          803       803           
  Lines        14804     14804           
  Branches      3911      3911           
=========================================
  Hits         14804     14804           

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

@codecov
Copy link

codecov bot commented Nov 23, 2025

Bundle Report

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

Detailed changes
Bundle name Size Change
antd.min-array-push 3.91MB 8 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 4 bytes 2.15MB 0.0%
antd.min.js 4 bytes 1.76MB 0.0%

@PeachScript PeachScript mentioned this pull request Dec 2, 2025
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.

2 participants