Skip to content

fix(table): correct alignment with a table cell that contains a button#7551

Merged
mcoker merged 5 commits intopatternfly:mainfrom
sg00dwin:7534-table-actions-button-alignment-bug
Jun 18, 2025
Merged

fix(table): correct alignment with a table cell that contains a button#7551
mcoker merged 5 commits intopatternfly:mainfrom
sg00dwin:7534-table-actions-button-alignment-bug

Conversation

@sg00dwin
Copy link
Contributor

@sg00dwin sg00dwin commented May 28, 2025

#7534

Adds a new html example of table td cells that contain a button. A new modifier class sets cell padding so the button is aligned within the row of elements.

https://patternfly-pr-7551.surge.sh/components/table/html/table-with-buttons-and-actions/

@patternfly-build
Copy link
Collaborator

patternfly-build commented May 28, 2025

Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

WDYT about mobile view? @andrew-ronaldson
image

@andrew-ronaldson
Copy link
Collaborator

Good question. I'd prefer if the button wasvertical-align:center Would that make that row look weird?

@kmcfaul kmcfaul linked an issue Jun 4, 2025 that may be closed by this pull request
3 tasks
@sg00dwin
Copy link
Contributor Author

@andrew-ronaldson I updated the mobile view so that the td cell content are align-items: center
Screenshot 2025-06-10 at 5 07 52 PM

@srambach
Copy link
Member

The only thing is, at mobile width, anything that wraps is now going to be centered vertically.
image

Since you have the .#{$table}__td-button class, can you scope the vertical alignment just to that?

@sg00dwin
Copy link
Contributor Author

sg00dwin commented Jun 12, 2025

Targeted .#{$table}__td-button with specificity to align center!

Screenshot 2025-06-12 at 3 46 48 PM

@sg00dwin sg00dwin force-pushed the 7534-table-actions-button-alignment-bug branch from c324ea9 to 5aa786f Compare June 12, 2025 19:52
Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

Just one nit on the name - if that's good then it all looks good to me!

| `.pf-v6-c-table__check` | `<th>`, `<td>` | Initiates a checkbox or radio input table cell. |
| `.pf-v6-c-table__action` | `<th>`, `<td>` | Initiates an action table cell. |
| `.pf-v6-c-table__inline-edit-action` | `<th>`, `<td>` | Initiates an inline edit action table cell. |
| `.pf-v6-c-table__td-button` | `<td>` | Initiates an table cell with button. |
Copy link
Member

Choose a reason for hiding this comment

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

Just want to get @mcoker's thought about the name of this element - this is a tough one and I feel like it should be pf-v6-c-table__td--button (double hyphen) but I am not sure.

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

I would probably call that "action" instead of button since it can hold anything form-element size, which would most likely be buttons and menu toggles, and we generally refer to those as actions instead of buttons. We already have __action as the action cell, but I think .pf-m-action would work since it's more generic to denote any cell has an action (or actions), and you can have multiple of them, compared to __action which is the action cell for the row. wdyt?

@srambach
Copy link
Member

I would probably call that "action" instead of button since it can hold anything form-element size, which would most likely be buttons and menu toggles, and we generally refer to those as actions instead of buttons. We already have __action as the action cell, but I think .pf-m-action would work since it's more generic to denote any cell has an action (or actions), and you can have multiple of them, compared to __action which is the action cell for the row. wdyt?

Yeah, I think that makes sense to me

@sg00dwin
Copy link
Contributor Author

@mcoker @srambach Updated modifier class name
8cebd30

Comment on lines 202 to 207
--#{$table}__td-button--PaddingBlockStart: var(--pf-t--global--spacer--sm);
--#{$table}__td-button--PaddingBlockEnd: var(--pf-t--global--spacer--sm);

// * Table compact cell with button
--#{$table}--m-compact__td-button--PaddingBlockStart: var(--pf-t--global--spacer--xs);
--#{$table}--m-compact__td-button--PaddingBlockEnd: var(--pf-t--global--spacer--xs);
Copy link
Member

Choose a reason for hiding this comment

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

Should these variable names also change to --m-action ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are now updated with modifier name

@sg00dwin
Copy link
Contributor Author

@mcoker @srambach PR has been updated addressing latest comments and ready for another review.

Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

L 🥳 TM!

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

lgtm! Just a couple of small comments

--#{$table}--cell--PaddingBlockEnd: var(--#{$table}--m-compact__action--PaddingBlockEnd);
}

.pf-m-action {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you tie this modifier class to the table element it applies to?

Suggested change
.pf-m-action {
.#{$table}__td.pf-m-action {

6
{{/table-td}}
{{#> table-td table-td--data-label="Start Build" table-td--modifier="pf-m-action"}}
<span class="pf-v6-c-table__text">
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make this a regular <span>? the __text element works, but it's more intended for use with the modifiers that manipulate text (nowrap, truncate, etc)

Suggested change
<span class="pf-v6-c-table__text">
<span>

2
{{/table-td}}
{{#> table-td table-td--data-label="Start Build" table-td--modifier="pf-m-action"}}
<span class="pf-v6-c-table__text">
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<span class="pf-v6-c-table__text">
<span>

7
{{/table-td}}
{{#> table-td table-td--data-label="Start Build" table-td--modifier="pf-m-action"}}
<span class="pf-v6-c-table__text">
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<span class="pf-v6-c-table__text">
<span>

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

🎃

@mcoker mcoker merged commit 3bb2df2 into patternfly:main Jun 18, 2025
4 checks passed
@patternfly-build
Copy link
Collaborator

🎉 This PR is included in version 6.3.0-prerelease.36 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug - Table - Actions dropdown misaligned with button

5 participants