Skip to content

fix(grid): fix align prop not working on table body columns (#4230) - #4262

Closed
Georgyhongbo wants to merge 1 commit into
opentiny:devfrom
Georgyhongbo:fix/grid-align-column
Closed

fix(grid): fix align prop not working on table body columns (#4230)#4262
Georgyhongbo wants to merge 1 commit into
opentiny:devfrom
Georgyhongbo:fix/grid-align-column

Conversation

@Georgyhongbo

@Georgyhongbo Georgyhongbo commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

The align prop was only applied to header columns via CSS. Body and footer columns were missing the col__center and col__right CSS rules, causing the align attribute to have no effect on data cells.

This fix adds justify-content alignment rules for body and footer columns, and includes body columns in the flex layout selector to ensure the alignment classes take effect.

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

When using <tiny-grid-column align="center"> or align="right", the alignment only takes effect on header columns. Body and footer columns remain left-aligned regardless of the align prop value.

Issue Number: #4230

What is the new behavior?

The align prop now works correctly on all columns — header, body, and footer. Body and footer cells respect align="center" and align="right" just like header cells do.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Only CSS changes in packages/theme/src/grid/table.less. The fix mirrors the existing header column alignment pattern for body and footer columns.

Summary by CodeRabbit

  • Bug Fixes
    • Improved table column alignment for centered and right-aligned header and body cells.
    • Applied consistent flex layout and ellipsis styling across header and body columns.
    • Preserved specialized behavior for selection columns.

…#4230)

The align prop was only applied to header columns via CSS. Body and
footer columns were missing the col__center and col__right CSS rules,
causing the align attribute to have no effect on data cells.

This fix adds justify-content alignment rules for body and footer
columns, and includes body columns in the flex layout selector to
ensure the alignment classes take effect.
@github-actions github-actions Bot added the bug Something isn't working label Jul 26, 2026
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Updated grid table LESS selectors so center/right alignment targets the intended cell class and shared flex styling applies to both header and body columns, excluding selection columns.

Changes

Table column alignment styling

Layer / File(s) Summary
Update table column alignment selectors
packages/theme/src/grid/table.less
Center and right justification now targets @{grid-cell-prefix-cls}, and the related flex and column variant rules apply to both header and body columns except .col__selection.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested labels: bug

Poem

I’m a bunny with a table to align,
Center and right now fall in line.
Header and body share the view,
Selection columns stay out of queue.
Hop, hop—clean styles shine!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main bug fix: grid column alignment not working on table body columns.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/theme/src/grid/table.less`:
- Around line 595-596: Extend the flex-layout selector covering
`&-header__column` and `&-body__column` to also include `&-footer__column`,
while preserving the existing exclusion for `.col__selection` so footer
alignment modes receive the same flex-container behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9c212624-81b8-43c2-b268-d4b0d8a17304

📥 Commits

Reviewing files that changed from the base of the PR and between e5e921b and e3ac33f.

📒 Files selected for processing (1)
  • packages/theme/src/grid/table.less

Comment on lines +595 to +596
& &-header__column:not(.col__selection),
& &-body__column:not(.col__selection) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Include footer columns in the flex-layout selector.

The preceding block applies justify-content to both body and footer cells, but this selector only makes header and body cells flex containers. Footer align="center"/align="right" can therefore remain ineffective unless another stylesheet supplies display: flex.

Proposed fix
   & &-header__column:not(.col__selection),
-  & &-body__column:not(.col__selection) {
+  & &-body__column:not(.col__selection),
+  & &-footer__column:not(.col__selection) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
& &-header__column:not(.col__selection),
& &-body__column:not(.col__selection) {
& &-header__column:not(.col__selection),
& &-body__column:not(.col__selection),
& &-footer__column:not(.col__selection) {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/theme/src/grid/table.less` around lines 595 - 596, Extend the
flex-layout selector covering `&-header__column` and `&-body__column` to also
include `&-footer__column`, while preserving the existing exclusion for
`.col__selection` so footer alignment modes receive the same flex-container
behavior.

@shenjunjian

shenjunjian commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

看文档 表格/对齐方式,有 header-align 与 footer-align 专门用来控制表头,表脚的对齐方式。

你再确认一下是不是你需要的功能。 稍后我会关闭本次pr

@Issues-translate-bot

Copy link
Copy Markdown

Bot detected the issue body's language is not English, translate it automatically.


Looking at the documentation, there are header-align and footer-align specifically used to control the alignment of the header and footer.

Please confirm again whether it is the function you need. I will close this PR later

@shenjunjian shenjunjian added invalid This doesn't seem right (无效的单) and removed bug Something isn't working labels Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

invalid This doesn't seem right (无效的单)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants