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
Fix Carousel Transition Bug #5678
Fix Carousel Transition Bug #5678
Conversation
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.
Looking great. Thank you, @kevingill55.
Just a couple minor comments.
CarouselChild.propTypes = { | ||
fill: PropTypes.bool, | ||
play: PropTypes.number, | ||
index: PropTypes.number.isRequired, | ||
activeIndex: PropTypes.number.isRequired, | ||
priorActiveIndex: PropTypes.number, | ||
}; | ||
|
||
CarouselChild.defaultProps = { | ||
fill: false, | ||
play: undefined, | ||
priorActiveIndex: undefined, | ||
}; |
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.
Thoughts on keeping all the propType definitions consolidated in the Carousel/prop-types.js
file for consistency? Can export CarouselChildPropType
from there and consume it here. I think that would mimic the pattern implemented throughout the rest of the project.
/** | ||
* This check will only be false onMount of the component. It ensures | ||
* the initial active slide of the Carousel renders with no animation. | ||
*/ |
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.
👍
setTimeout( | ||
() => setVisibility('hidden'), | ||
theme.carousel.animation.duration, | ||
); |
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.
I think we need to clean up this useEffect's timer after the component unmounts.
Here are references to a couple Grommet instances where this pattern is used:
Other references:
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.
Ah yes! Great point
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.
Thank you, @kevingill55!
Thanks for your contribution! |
What does this PR do?
This fixes a regression introduced to the
Carousel
component that caused un-smooth and jarring transitions between Carousel slides. The issue is caused when the user changes the current slide, and thevisibility
property is set tohidden
before the slide can complete its animation of fading out. Thus, the current child is immediately removed while the next child is slowly sliding in.Where should the reviewer start?
The only changes were made in the
Carousel/Carousel.js
file.What testing has been done on this PR?
The accessibility issue that this regression was introduced in is still fixed. All other functionality of the component is maintained.
How should this be manually tested?
Run storybook and see the Carousel stories. Make sure the accessibility issue that this PR fixed is still working. Also, ensure that the Carousel transitions between slides are smooth and as expected. Compare the transitions with what is on
master
.What are the relevant issues?
#5675
Do the grommet docs need to be updated?
No
Should this PR be mentioned in the release notes?
Yes
Is this change backwards compatible or is it a breaking change?
Backwards compatible 👍