Skip to content

fix(dual-list-selector): animate tree expansion#7493

Merged
mcoker merged 10 commits intopatternfly:mainfrom
mcoker:issue-7325
May 20, 2025
Merged

fix(dual-list-selector): animate tree expansion#7493
mcoker merged 10 commits intopatternfly:mainfrom
mcoker:issue-7325

Conversation

@mcoker
Copy link
Copy Markdown
Contributor

@mcoker mcoker commented Apr 30, 2025

fixes #7325
fixes #7530

@patternfly-build
Copy link
Copy Markdown
Collaborator

patternfly-build commented Apr 30, 2025

@mcoker mcoker requested a review from andrew-ronaldson April 30, 2025 14:16
Copy link
Copy Markdown
Collaborator

@andrew-ronaldson andrew-ronaldson left a comment

Choose a reason for hiding this comment

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

Crushing these issues bruh!

@mcoker
Copy link
Copy Markdown
Contributor Author

mcoker commented May 9, 2025

@kmcfaul @thatblindgeye looks like dual list selector tree in react conditionally renders the nested items when they're expanded. I think that happens right here - https://github.com/patternfly/patternfly-react/blob/f8b21b594c90960305e3b58b723c1cff7a9decbb/packages/react-core/src/deprecated/components/DualListSelector/DualListSelectorTreeItem.tsx#L159

I think we'll need to either

  1. To keep everything the way it is in the DOM now and continue to conditionally render
    • On expand, render the nested tree as we do now, then use the setTimeout() method to apply .pf-m-expanded on the parent item.
    • On collapse, wait for the transitionend event of the nested tree before unmounting
  2. Let CSS manage hiding/showing the nested tree. That would probably mean the react component always renders the nested tree. Then the rest can be managed with CSS.

Do you have a preference? Or any other thoughts?

@thatblindgeye
Copy link
Copy Markdown
Contributor

@mcoker gonna try fiddling around with React locally using this PR update, but at the moment I feel like personally I might lean towards making it more opt-in for React for now and updating in the next breaking change to be the default (similar to Alert).

  • Making it opt in means it won't be breaking for consumers to have the dual list selector content always rendered rather than dynamically rendered
  • Avoids any potential issues relying on the timeout to add that class to get animations working
  • Would be consistent with how the other expansion animations on ExpandableSection and Accordion are working right now

@thatblindgeye
Copy link
Copy Markdown
Contributor

@mcoker @kmcfaul I think I have something locally that may not require a setTimeout but still work. There is an issue with nested tree view items in the DLS component, though, and seems like it's also in Core.

Toggling the pf-m-expanded class on a top most tree view item in the dual list selector with tree example animates fine (the "Colors" item). But trying to toggle an item nested in that one (e.g. "Green") doesn't have the animations I'd expect.

@kmcfaul
Copy link
Copy Markdown
Contributor

kmcfaul commented May 12, 2025

I think I'd lean more towards a core solution with maybe an opt-in prop on react's side to allow the children to always be rendered, but I also think @thatblindgeye's solution avoiding the timeout and toggling the expanded class is good as well. The only issue I see is that the nested tree folders aren't being hidden when collapsed.

@mcoker
Copy link
Copy Markdown
Contributor Author

mcoker commented May 13, 2025

@kmcfaul @thatblindgeye fixed the nested item bug and converted it to transition display for the hide/show instead of relying on hidden

Copy link
Copy Markdown
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.

In React this looks great. The only thing is that by default (just the tree example as it curently is in React) the expand animation will still occur, but there's no collapse animation. Adding a hasAnimations prop and setting that up gets things working as expected, it's just the current behavior where the children are dynamically rendered rather than always rendered.

Would we be able to add a temporary class to disable animations for the current behavior, then in the next breaking change remove it (and the prop we'd need in React to get animations working)?

@mcoker
Copy link
Copy Markdown
Contributor Author

mcoker commented May 13, 2025

@thatblindgeye forgot about that! Added, .pf-m-animate-expand that goes on the outer .pf-v6-c-dual-list-selector wrapper.

Copy link
Copy Markdown
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.

insert magneto-perfection.gif

Looks like this should work in React!

@mcoker mcoker requested review from sg00dwin and srambach May 13, 2025 18:03
.#{$dual-list-selector}.pf-m-animate-expand & {
// stylelint-disable max-nesting-depth, selector-max-class
&:where([hidden]) {
display: flex;
Copy link
Copy Markdown
Contributor

@sg00dwin sg00dwin May 15, 2025

Choose a reason for hiding this comment

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

I'm not following why this rule is needed. .#{$dual-list-selector}__list looks to be removed from the dom when in the unexpanded state.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sg00dwin good catch, that was a copy/paste from another component.

@sg00dwin
Copy link
Copy Markdown
Contributor

I'm not seeing it animate on collapse. Should it?
dual-list-selector-animate

@mcoker
Copy link
Copy Markdown
Contributor Author

mcoker commented May 19, 2025

@sg00dwin if you're testing in react, it won't collapse because react removes the nested menu from the DOM on collapse. But that's going to change so that react always renders the element - @thatblindgeye and I have tested it on the react side so it should be GTG now!

@mcoker mcoker requested a review from sg00dwin May 19, 2025 18:39
Copy link
Copy Markdown
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 the one question about if we want to leave a breaking change comment for later.

--#{$dual-list-selector}__item--PaddingInlineStart: var(--#{$dual-list-selector}__item--m-expandable--PaddingInlineStart);

> .#{$dual-list-selector}__list {
.#{$dual-list-selector}.pf-m-animate-expand & {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we want to leave a TODO anywhere about removing the opt-in in a breaking change?

@mcoker mcoker requested a review from srambach May 20, 2025 20:32
@mcoker mcoker merged commit 288e718 into patternfly:main May 20, 2025
4 checks passed
@mcoker mcoker deleted the issue-7325 branch May 20, 2025 21:42
@patternfly-build
Copy link
Copy Markdown
Collaborator

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

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.

Expandable section - keep animation from firing on page load Animation: Dual list - Expand/collapse interaction

7 participants