Skip to content

(Collapsible) fix: enable animation when initial open prop is true #6535

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

Merged
merged 2 commits into from
Dec 16, 2022

Conversation

buberdds
Copy link
Contributor

@buberdds buberdds commented Dec 9, 2022

What does this PR do?

Fixes animation speed value. When component is open on init nextSpeed value is NaN because sizeRef returns undefined at this point and this value is used in nextSpeed computation.

Where should the reviewer start?

Collapsible.js

What testing has been done on this PR?

manual

How should this be manually tested?

set initial open prop to true

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

What are the relevant issues?

Closes #6523

Screenshots (if appropriate)

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?

no

@buberdds buberdds changed the title (Collapsible) fix: enable animation when initial open prop is set to … (Collapsible) fix: enable animation when initial open prop is true Dec 9, 2022
Copy link
Collaborator

@jcfilben jcfilben 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!

@@ -77,7 +77,7 @@ const Collapsible = forwardRef(
collapsible: { minSpeed, baseline },
} = theme;
const nextSpeed = Math.max(
(sizeRef.current / baseline) * minSpeed,
((sizeRef.current || 0) / baseline) * minSpeed,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a cleaner way to do this would be to adjust the useRef to be useRef(0), that way it starts with an initial value.

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.

Opened by default, collapsible does not do the animation
3 participants