-
Notifications
You must be signed in to change notification settings - Fork 371
feat(Alert): added animations #11495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Preview: https://patternfly-react-pr-11495.surge.sh A11y report: https://patternfly-react-pr-11495-a11y.surge.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the demo be updated?
I can see the alert gets the |
@tlabaj possibly a question for design? I wasn't sure if we wanted all of our AlertGroup instances to have animations on by default or not. If we do, we could update the new prop default to be true
@srambach I think the issue is that the Alert gets removed too quickly for the full transition to be seen. If you look at the left edge of an Alert as you press the "close" button for it, you should be able to see that it starts to transition to the right, it just derenders so quickly. I could fiddle with the timeout between that offstage-right class getting applied and the alert actually being removed. |
Notes from animations review meeting:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, code looks good, tested fine, nice work.
This has nothing to do with your code or implementation but as an end user I would expect animations on alert close to do the exact opposite direction of on open. So if it the animation of the alert makes it move down from top, the animation on close should have it move up back to top. Likewise, if it animates in from left on open, it should animate to right on close. In other words, returning to the place from which it came. :) But this is a comment on the design not the implementation, so I digress.
Met with @mcoker and @srambach yesterday afternoon to discuss this PR, specifically using the transitionend event when alerts are removed rather than using a CSS token+setTimeout. The latest commit is an attempt at doing that as well as updating animations to be enabled by default (cc @andrew-ronaldson ). Some notes:
|
9d0010e
to
260bca0
Compare
260bca0
to
f96cd3a
Compare
@@ -0,0 +1,76 @@ | |||
import React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since hasAnimations
is true by default. I would say this examples is not technically needed correct? I wonder if we can combine the docs from this with another example. @edonehoo I would be interested in your thoughts here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I would agree that this example doesn't seem necessary if hasAnimations is the default behavior.
Or I'm wondering what we're trying to explain via this example that we aren't doing in previous examples? Is it this part? "When using animations, each alert must have a unique id or key passed to it."
We could add an asterisk/update the description of id in the props table saying that it's required when using animations? And/or add that to the hasAnimations description
const shouldDismiss = timedOut && timedOutAnimation && !isMouseOver && !containsFocus; | ||
const [isDismissed, setIsDismissed] = React.useState(false); | ||
const { hasAnimations } = React.useContext(AlertGroupContext); | ||
const { offstageRight } = alertGroupStyles.modifiers; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to account for RTL with alert groups and the animations - like have an offstageLeft
?
Also, right now the full page demo with toast alerts doesn't seem to work at all when you flip on RTL (alerts do not pop up and the notification drawer doesn't open/close until you turn off RTL again).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great Question!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
patternfly/patternfly#7365 to address RTL.
f96cd3a
to
9cebdda
Compare
Latest commit 8 includes some refactoring of how to handle the transitionend logic - rather than adding eventlisteners to the document (would create a lot of noise), logic is passed to the onTransitionEnd handler of the AlertGroupItem. I kept the hasAnimations prop, as that may be necessary for consumers to pass as false for testing purposes. The class modifier killswitch didn't work from what I had tried in getting this test to pass. You can see what we had to do to get one of the AlertGroup tests to pass. Keep in mind that this might only be an issue if a consumer is specifically testing the Alert's Also a note: the original implementation where I had used timeouts instead of leveraging the transitionend (from the first commit), also would've required an update to the AlertGroup test (albeit slightly simpler). |
6cae51a
to
4841c62
Compare
4841c62
to
261fe00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨 good to go from my perspective!
const { | ||
className, | ||
children, | ||
hasAnimations = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be opt-in rather than opt-out? It looks like at least one of our cypress demos needed an update to turn animations off in this PR, so I'm concerned this may be breaking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if this should be opt-in or not! ^ wdyt? @thatblindgeye
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything else lgtm so I'll leave an approval, but I would love some feedback about my above comment about the current opt-out pattern of the new prop though.
I think we should probably make this and other animations opt-in personally, until V7 where we can make them default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm from the design side!
@thatblindgeye Can we just turn off the animations internally? If the animations "kill switch" style is applied in the DOM we turn animations off in Alerts? That way the kill switch will control turning off all animations. |
261fe00
to
1695416
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The one last thing I noticed is that we updated our demos to put new alerts at the beginning on the alert array instead of appending them, so that has some implication for users (just testing on the updated preview with the animations on and that change reverted - because the animation is triggered on the first item, additional alerts appended to the array will be added but not have the animation triggered). But since it's now opt in, I think that's part of opting in as well as updating tests.
Followup to discussions from today: #11684 |
What: Closes #10440
Some specific input from design: does the animation on removal go too quickly? I'm using (I believe) the token value for the transition used in Core (100ms). When I had originally tried hardcoding a timeout I used 200ms (so 200ms from the Alert being clicked to remove/timed out to it actually being removed from the DOM) and that looked a tad nicer IMO, but using an arbitrary length of time like that may not be great + just *2 the token value may not be great either if the default value from Core/overrides gets too be too long
Additional issues: