Skip to content

fix(table): updated expandable to animate visibility#7537

Merged
mcoker merged 13 commits intopatternfly:mainfrom
mcoker:issue-7536
Jun 11, 2025
Merged

fix(table): updated expandable to animate visibility#7537
mcoker merged 13 commits intopatternfly:mainfrom
mcoker:issue-7536

Conversation

@mcoker
Copy link
Contributor

@mcoker mcoker commented May 20, 2025

fixes #7536

@patternfly-build
Copy link
Collaborator

patternfly-build commented May 20, 2025

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Tested this against the React PR that resolves the divider issue patternfly/patternfly-react#11815 and it mostly looks good. The one thing I'm noticing is when you click to collapse a table row, the divider line appears as the expandable row is collapsing (causing the table to look like it has an empty row momentarily). I think it's really only noticeable at 25 or 10% animation speed, though.

My mac isn't currently letting my screen record so pictures instead:

PatternFly table example showing how expandable animations causes the table to momentarily look like it has an empty table row as the expandable row is animating out.

@srambach
Copy link
Member

Tested this against the React PR that resolves the divider issue patternfly/patternfly-react#11815 and it mostly looks good. The one thing I'm noticing is when you click to collapse a table row, the divider line appears as the expandable row is collapsing (causing the table to look like it has an empty row momentarily). I think it's really only noticeable at 25 or 10% animation speed, though.

Does it have to do with the border-block-end: revert on line 1051 and/or not everything is getting marked as expanded as it should?
There are 3 elements with .pf-m-expanded and if you toggle the table__tr that's not the expandable row, it creates an extra border

image

@srambach
Copy link
Member

There's a problem with the compound expansion example - looks like maybe changing them to visibility instead of display:none means they are taking space.

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Other than ^ lgtm, animations work nicely when pulled into React (with the fixes for the divider bug that got merged in react)

@mcoker
Copy link
Contributor Author

mcoker commented May 21, 2025

@srambach can you check again?

I'm assuming we should animate compound expandable, too? At least the initial click on a compound expandable item, but also possibly a fade between items once one is expanded when clicking on a different item. cc @andrew-ronaldson wdyt? Here's a link to compound expandable in react - https://www.patternfly.org/components/table/react/compound-expandable/

Copy link
Contributor

@sg00dwin sg00dwin left a comment

Choose a reason for hiding this comment

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

LGTM

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.

It looks like compound expandable shows all the non-expanded rows unless .pf-m-animate-expand is on the table. Are we keeping display: none in that case so we don't break core users?

Also, I think we need to add .pf-m-animate-expand in the docs at the appropriate spot.

| `.pf-v6-c-table__control-row` | `.pf-v6-c-table__expandable > <tr>` | Modifies a compound expandable table control row. |
| `.pf-m-expanded` | `<tbody>`, `.pf-v6-c-table__compound-expansion-toggle` > `.pf-v6-c-button` | Modifies a tbody with a row and an expandable row. |
| `.pf-v6-c-table__compound-expansion-toggle` | `<td>` | Modifies a `<td>` on active/focus. |
| `.pf-m-expanded` | `<tbody>`, `.pf-v6-c-table__compound-expansion-toggle` > `.pf-v6-c-button` | Modifies a tbody with a row and an expandable row. |
Copy link
Member

Choose a reason for hiding this comment

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

This wording is confusing - modifies a tbody that contains ... and an expanded toggle (?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was already there (I didn't add it) but I took a stab. It looks like the selectors were wrong, too.

| `.pf-m-expanded` | `<tbody>`, `.pf-v6-c-table__compound-expansion-toggle` > `.pf-v6-c-button` | Modifies a tbody with a row and an expandable row. |
| `.pf-v6-c-table__compound-expansion-toggle` | `<td>` | Modifies a `<td>` on active/focus. |
| `.pf-m-expanded` | `<tbody>`, `.pf-v6-c-table__compound-expansion-toggle` > `.pf-v6-c-button` | Modifies a tbody with a row and an expandable row. |
| `.pf-m-no-background` | `.pf-v6-c-table__expandable-row-content` | Modifies the expandable row content to have a transparent background. For in compound expandable when the parent expandable row has no padding with `.pf-m-no-padding`. |
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
| `.pf-m-no-background` | `.pf-v6-c-table__expandable-row-content` | Modifies the expandable row content to have a transparent background. For in compound expandable when the parent expandable row has no padding with `.pf-m-no-padding`. |
| `.pf-m-no-background` | `.pf-v6-c-table__expandable-row-content` | Modifies the expandable row content to have a transparent background. For use in compound expandable when the parent expandable row has no padding with `.pf-m-no-padding`. |

Comment on lines 1027 to 1028
&:not(.pf-m-expanded) {
display: none;
Copy link
Member

Choose a reason for hiding this comment

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

Does this need to remain or use another method to hide rows that aren't expanded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added back, missed that completely. That hides the non-expanded rows in a non-expandable table.

@mcoker mcoker requested a review from srambach June 10, 2025 02:13
@mcoker
Copy link
Contributor Author

mcoker commented Jun 10, 2025

@srambach thanks! I should have caught the non-animated rows showing!

Updated and added new examples with the animated class for regular and compound expandable.

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Repeat from Slack convo below, but a couple things I'm noticing when pulling these updates into React with updates made there:

  • In Core we need to apply the pf-m-animate-expand class to the outer table element. Doing that will show an issue seen in React where when anything but the 1st compound expandable section is expanded, there's a border above the expandable content. I assume it's due to some tr + tr selector not taking into account this animate-expand modifier? The core compound expandable looks fine when updating the classes so the second compound expansion button+content is expanded, it's not until you add the missing pf-m-animate-expand to the outer table where you can reproduce the issue
  • If content within the pf-v6-c-table__expandable-row-content element has a margin (as it does in React examples/demos for compound expansion), that margin continues to take up space when collapsed. Updating the React examples/demos to use the padding utility class instead of the margin one should resolve the issue, but just wondering if we want to handle a case of margin being used.

Not from Slack, but also examples will need to be updates so that hidden and inert are added to the collapsed rows.

@srambach
Copy link
Member

I think now the top padding is missing on tabs that aren't the first one? You can see in the inspector that padding-block-start is 0 if it's not immediately following a control row

2025-06-11_10-24-34.mp4

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Looks good when linked to my React draft!

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.

I'm good with a follow-on later to see if we can improve the bounce when switching from one compound expandable to another.

@mcoker mcoker merged commit a8e2447 into patternfly:main Jun 11, 2025
4 checks passed
@mcoker mcoker deleted the issue-7536 branch June 11, 2025 17:02
@patternfly-build
Copy link
Collaborator

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

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.

Table - update expandable to animate visibility

6 participants