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(modal): OpenCloseComponent emits when setting --calcite-duration-factor to 0 #5326

Conversation

Elijbet
Copy link
Contributor

@Elijbet Elijbet commented Sep 14, 2022

Related Issue: #5206

All (before)open/close events are now emitted on modal regardless of transition duration.

Add the onToggleUnanimatedComponent function to the openCloseComponent Interface to query props on the transitionEl. Use that to get the transition-duration on the openTransitionProp, which in the case of modal it’s the opacity. This will allow us to emit the open/close and beforeOpen/beforeClose events in cases where opacity transition duration is set to 0.

Because calling computed style forces a layout, we use readTask() instead which schedules a DOM-read task. The provided callback will be executed at the best moment to perform DOM reads without causing layout thrashing as per Stencil docs.

Updated to rework openCloseComponent Interface to call one function instead of 3 separate calls in every component by removing connect/disconnect and event listener mapping logic and passing argument once to .addEventListener on transitionEl instead.

@github-actions github-actions bot added the bug Bug reports for broken functionality. Issues should include a reproduction of the bug. label Sep 14, 2022
@github-actions github-actions bot added the Stale Issues or pull requests that have not had recent activity. label Sep 22, 2022
@Esri Esri deleted a comment from github-actions bot Oct 5, 2022
@Elijbet Elijbet marked this pull request as ready for review October 5, 2022 00:28
@Elijbet Elijbet requested a review from a team as a code owner October 5, 2022 00:28
src/components/modal/modal.e2e.ts Outdated Show resolved Hide resolved
src/utils/openCloseComponent.ts Outdated Show resolved Hide resolved
src/utils/openCloseComponent.ts Outdated Show resolved Hide resolved
src/components/modal/modal.tsx Outdated Show resolved Hide resolved
src/utils/openCloseComponent.ts Outdated Show resolved Hide resolved
src/utils/openCloseComponent.ts Show resolved Hide resolved
@Elijbet Elijbet marked this pull request as draft October 6, 2022 22:25
@Elijbet Elijbet requested a review from jcfranco November 9, 2022 20:08
@Elijbet Elijbet removed the Stale Issues or pull requests that have not had recent activity. label Nov 9, 2022
@@ -134,6 +130,7 @@ export class Modal
setUpLoadableComponent(this);
// when modal initially renders, if active was set we need to open as watcher doesn't fire
if (this.open) {
onToggleOpenCloseComponent(this);
Copy link
Member

Choose a reason for hiding this comment

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

Calling this here will emit these events on load of the component. Is there some history on why we are emitting on load here? Usually for components, we don't emit events initially, we start emitting after load on user interaction.

If this is intentional, the test will need to be updated to expect the event to be called initially.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The discussion on this is moved to #4398.

@github-actions
Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity. Please close your PR if it is no longer relevant. Thank you for your contributions.

@github-actions github-actions bot added the Stale Issues or pull requests that have not had recent activity. label Nov 30, 2022
Copy link
Contributor

@alisonailea alisonailea left a comment

Choose a reason for hiding this comment

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

There are some issues and questions to resolve here.

@Elijbet Elijbet removed the Stale Issues or pull requests that have not had recent activity. label Dec 1, 2022
@Elijbet Elijbet marked this pull request as draft December 2, 2022 21:00
@Elijbet Elijbet marked this pull request as ready for review December 5, 2022 22:11
@Elijbet Elijbet added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Dec 5, 2022
Copy link
Member

@driskull driskull 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 @Elijbet !! Nice work!!! 🎉

@Elijbet Elijbet merged commit ff19420 into master Dec 6, 2022
@Elijbet Elijbet deleted the elijbet/5206-OpenCloseComponents-emit-with-transition-duration-0 branch December 6, 2022 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports for broken functionality. Issues should include a reproduction of the bug. pr ready for visual snapshots Adding this label will run visual snapshot testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants