-
-
Notifications
You must be signed in to change notification settings - Fork 79.2k
Fix handling of transitionend events dispatched by nested elements #33845
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
0199be3 to
5d73f20
Compare
|
Is this ready for review and shipping with v5.0.1? |
92e64d5 to
349e414
Compare
349e414 to
aead9dd
Compare
68cb2cb to
4c3c946
Compare
|
@alpadev would it be OK to move this to 5.0.2? I plan to make the release soon, and I'm unsure if we should land this in such a hurry :) |
4c3c946 to
2064073
Compare
Proceed as you wish, I don't mind. Been quite busy and missed the information in slack that we would do a release today. Otherwise I would have tried to focus more on this PR. |
9c4bb8a to
106bbca
Compare
a0c2f97 to
707ef8e
Compare
|
Now that we have time, guys do you consider changing the I am asking this, cause as Alpa said, the footprint of this change will be less compared with the extra function approach CC/ @XhmikosR |
|
Technically, it could be a BC, but since we are not exposing directly the utils, I'd say we can make the change, if it helps us. At some point, we should expose our utils, but that's for another time. |
ca844bc to
651dca6
Compare
Merged the emulateTransitionEnd and added some condition so the static background transition isn't triggered. I kindly ask you to review it again.
651dca6 to
9bd88b0
Compare
9bd88b0 to
fd016ac
Compare
js/src/util/index.js
Outdated
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.
Although the comment was not present here before, 5 seems the magic number here thus it is better to put a nice comment 🙂
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 what to comment here.. I tried to find out why it's 5 but I have no idea.. Considering that one frame of a 60fps animation is about 16ms - 5ms seems basically nothing.
AFAICT the idea behind this emulation code was to dispatch a transitionend event if no other transitionend event had been triggered. Likely as a fallback for legacy browsers that don't support them.
I guess the intention was to add some additional duration so the timeout will finish after the native transition event in case the browser dispatch it. That's hard to enforce tho since we're not starting any transition here (or tracking its state) but only adding some listener and a timeout that would trigger after the calculated duration no matter what.
Also getTransitionDurationFromElement only respects the duration of one (the first) CSS transition. If there are multiple transitions defined and one that takes longer (which isn't the first one) setTimeout might finish too early. (This shouldn't be the case with our defaults from what I can tell.)
In general since the timeout triggers a (custom) transitionend event and we don't match or verify them, this could lead to inconsistencies. For example the browser takes longer for the transition, setTimeout will trigger an event, then the browser triggers another event for the same transition.
On a sidenote, native transitionend events in the test environment seem to be somewhat unreliable. No idea if this is some optimization the browser is doing because it's headless or the elements are rendered offscreen (because of the fixture) or what exactly is causing this. setTimeout on the other hand works pretty reliable.
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.
/CC @Johann-S for the opinion ❤️
js/src/util/index.js
Outdated
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.
This flag variable (called) can not be omitted? @alpadev 🤔
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.
Although, there is no test covering the use of the called flag 🙂
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 about omitting this. I mean in theory we could, since the event handler unregisters itself, thus the callback is only executed once. But there would be another transitionend event dispatched by the setTimeout which could be a problem.
called is partly covered by
https://github.com/twbs/bootstrap/blob/fd016ac7ba9900f2275163d86c0d554d6a0d9b5a/js/tests/unit/util/index.spec.js#L665 because setTimeout wouldn't trigger an event if called is true.
I added another test that I hope will satisfy your objection. (I can't really verify the state of called since it's scoped to the function.)
https://github.com/twbs/bootstrap/blob/0c1d8fd9849be89f6f933b6b0017dc8f435c31c3/js/tests/unit/util/index.spec.js#L703
fd016ac to
0c1d8fd
Compare
|
@alpadev @rohit2sharma95 |
…elements fix: emulateTransitionEnd should properly handle events from nested elements fix: BaseComponent._queueCallback should not execute callback if event from nested elements refactor: use _queueCallback for static modal animation refactor: reuse _queueCallback from BaseComponent for backdrop animations feature: add executeAfterTransition utility function test: add spec for excuteAfterTransition function refactor: use executeAfterTransition in base-component and backdrop test: add test if static modal backdrop is clicked multiple times fix: callbacks are queued multiple times when static modal backdrop is clicked more than once test: added another test and updated timing/wording on executeAfterTransition tests test: ensure the functionality of triggerTransitionEnd refactor: merge emulateTransitionEnd with executeAfterTransition test: remove emulateTransitionEnd tests test: add another test for executeAfterTransition This is to assure that setTimeout wouldn't trigger another transitionend event if one had already happened
2cf6c6f to
4f12061
Compare
|
True @GeoSot, everything else LGTM 👍 |
…bs#33845) Fix handling of transitionend events dispatched by nested elements Properly handle events from nested elements Change `emulateTransitionEnd` to `executeAfterTransition` &&
Fixes #33682, fixes #33763, fixes #34066, fixes #31554 and fixes #33826.
Preview: https://deploy-preview-33845--twbs-bootstrap.netlify.app/