Skip to content
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

Merged
merged 6 commits into from Oct 13, 2021

Conversation

kevingill55
Copy link
Collaborator

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 the visibility property is set to hidden 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 👍

src/js/components/Carousel/Carousel.js Outdated Show resolved Hide resolved
src/js/components/Carousel/Carousel.js Show resolved Hide resolved
src/js/components/Carousel/Carousel.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@halocline halocline left a 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.

Comment on lines 60 to 72
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,
};
Copy link
Collaborator

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.

Comment on lines +22 to +25
/**
* This check will only be false onMount of the component. It ensures
* the initial active slide of the Carousel renders with no animation.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Comment on lines 39 to 42
setTimeout(
() => setVisibility('hidden'),
theme.carousel.animation.duration,
);
Copy link
Collaborator

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:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah yes! Great point

Copy link
Collaborator

@halocline halocline left a comment

Choose a reason for hiding this comment

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

Thank you, @kevingill55!

@ericsoderberghp ericsoderberghp merged commit cd415a6 into grommet:master Oct 13, 2021
@ericsoderberghp
Copy link
Member

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants