Skip to content

fix label-wrap when not required#53552

Merged
afc163 merged 3 commits intoant-design:masterfrom
pre1ude:patch-1
Apr 30, 2025
Merged

fix label-wrap when not required#53552
afc163 merged 3 commits intoant-design:masterfrom
pre1ude:patch-1

Conversation

@pre1ude
Copy link
Copy Markdown
Contributor

@pre1ude pre1ude commented Apr 18, 2025

中文版模板 / Chinese template

This is a fix for label wrap when not required and label is not middle align with input

Pasted image 20250417103701

reproduce demo: https://codesandbox.io/p/sandbox/biao-dan-biao-qian-ke-huan-xing-antd-5-24-7-forked-3sl8sg?file=%2Fdemo.tsx%3A20%2C17

  • 🆕 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 fix for label wrap when not required and label is not middle align with input
🇨🇳 Chinese 修复非必选的label换行不对齐的问题

@bolt-new-by-stackblitz
Copy link
Copy Markdown

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 18, 2025

📝 Walkthrough

Summary by CodeRabbit

  • 新功能

    • 表单示例中新增了一个带有超长标签文本的表单项,便于展示标签换行效果。
  • 样式

    • 优化了表单项标签的样式,使标签内容垂直居中并改善了长文本的换行表现。
## Summary by CodeRabbit

- **样式**
  - 优化了表单项标签包装器的直接子元素 `label` 的垂直对齐样式,新增 `verticalAlign: 'middle'``textWrap: 'balance'`- **示例**
  - 在表单示例中新增了一个带有超长标签文本的表单项,包含输入框但无校验规则。

## Walkthrough

本次更改在表单组件样式中,向表单项标签包装器的直接子元素 `label` 添加了 `verticalAlign: 'middle'``textWrap: 'balance'` 样式,调整标签的垂直对齐和文本换行方式。同时,在表单示例文件中新增了一个标签为“ A super long label text”的表单项,包含一个输入框但无校验规则,其他表单结构未变。

## Changes

| 文件路径                                   | 变更摘要                                                         |
|--------------------------------------------|------------------------------------------------------------------|
| components/form/style/index.ts              |`genFormItemStyle` 中,表单项标签包装器的直接子 `label` 添加了 `verticalAlign: 'middle'``textWrap: 'balance'` 样式。|
| components/form/demo/layout-can-wrap.tsx   | 新增一个标签为“ A super long label text”的表单项,包含输入框,无校验规则。|

## Suggested reviewers

- afc163

## Poem

> 兔子跳跃样式间,  
> 标签中增中线颜,  
> 文本平衡新姿态,  
> 输入框添长标签,  
> 代码细节巧安排。  
> 前端世界更自然,  
> 轻盈跃动不停歇!  
> 🐇✨

📜 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 18a2b6f and f3c5983.

📒 Files selected for processing (1)
  • components/form/style/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/form/style/index.ts
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 18, 2025

👁 Visual Regression Report for PR #53552 Failed ❌

🎯 Target branch: master (c8390de)
📖 View Full Report ↗︎
📖 Alternative Report ↗︎
📊 Summary: 🔄 6 changed, 🛑 1 removed

Expected (Branch master) Actual (Current PR) Diff
form-layout-can-wrap.compact.png form-layout-can-wrap.compact.png form-layout-can-wrap.compact.png form-layout-can-wrap.compact.png
form-layout-can-wrap.compact.png form-layout-can-wrap.compact.png form-layout-can-wrap.compact.css-var.png form-layout-can-wrap.compact.css-var.png
form-layout-can-wrap.dark.png form-layout-can-wrap.dark.png form-layout-can-wrap.dark.png form-layout-can-wrap.dark.png
form-layout-can-wrap.dark.png form-layout-can-wrap.dark.png form-layout-can-wrap.dark.css-var.png form-layout-can-wrap.dark.css-var.png
form-layout-can-wrap.default.png form-layout-can-wrap.default.png form-layout-can-wrap.default.png form-layout-can-wrap.default.png
form-layout-can-wrap.default.png form-layout-can-wrap.default.png form-layout-can-wrap.default.css-var.png form-layout-can-wrap.default.css-var.png
select-basic.mobile.css-var.png select-basic.mobile.css-var.png ⛔️⛔️⛔️ Missing ⛔️⛔️⛔️ 🚨🚨🚨 Removed 🚨🚨🚨

Important

There are 7 diffs found in this PR: 🔄 6 changed, 🛑 1 removed.
Please check all items:

  • Visual diff is acceptable

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 18, 2025

Preview is ready

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 18, 2025

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2025

Bundle Report

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

Detailed changes
Bundle name Size Change
antd.min-array-push 3.39MB 124 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 62 bytes 1.85MB 0.0%
antd.min.js 62 bytes 1.54MB 0.0%

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (c8bafcf) to head (f3c5983).
Report is 36 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #53552   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          769       769           
  Lines        13890     13903   +13     
  Branches      3644      3650    +6     
=========================================
+ Hits         13890     13903   +13     

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

@afc163
Copy link
Copy Markdown
Member

afc163 commented Apr 21, 2025

提供一个重现?

@afc163 afc163 requested a review from Copilot April 21, 2025 06:50
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

This PR fixes the label wrap misalignment issue for non-required form items by adjusting the line-height on the wrap container and restoring it on the nested label element.

  • Updated the label wrap style by setting the parent container’s line-height to 0 and explicitly applying token.lineHeight to its direct label child.
  • Ensures the vertical alignment of the label remains consistent with the input.

@pre1ude
Copy link
Copy Markdown
Contributor Author

pre1ude commented Apr 21, 2025

@afc163
Copy link
Copy Markdown
Member

afc163 commented Apr 21, 2025

加个 demo 用于 image snapshot 吧,避免之后改挂。

Copy link
Copy Markdown

@accesslint accesslint Bot left a comment

Choose a reason for hiding this comment

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

There are accessibility issues in these changes.

</Form.Item>

<Form.Item label="A super long label text" name="password1">
<Input />
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks like this element is missing an accessible name or label. That makes it hard for people using screen readers or voice control to use the control.

@pre1ude
Copy link
Copy Markdown
Contributor Author

pre1ude commented Apr 29, 2025

加个 demo 用于 image snapshot 吧,避免之后改挂。

added

Comment thread components/form/style/index.ts Outdated
pre1ude added 2 commits April 30, 2025 13:19
Signed-off-by: pre1ude <pre1ude@users.noreply.github.com>
@afc163
Copy link
Copy Markdown
Member

afc163 commented Apr 30, 2025

It is better for this situation: https://developer.mozilla.org/en-US/docs/Web/CSS/text-wrap

图片

@pre1ude
Copy link
Copy Markdown
Contributor Author

pre1ude commented Apr 30, 2025

It is better for this situation: https://developer.mozilla.org/en-US/docs/Web/CSS/text-wrap

图片

ok, added

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 30, 2025
@afc163 afc163 merged commit b23487e into ant-design:master Apr 30, 2025
40 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🎉 Thank you for your contribution! If you have not yet joined our DingTalk community group, please feel free to join us (when joining, please provide the link to this PR).

🎉 感谢您的贡献!如果您还没有加入钉钉社区群,请扫描下方二维码加入我们(加群时请提供此 PR 链接)。

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.

3 participants