-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
- Framework7 version: 7.0.8
- Platform and Target: Chrome + Firefox browsers, Android Cordova
- Live Link or CodeSandbox: https://codesandbox.io/p/sandbox/dazzling-feather-0s7qc6
Describe the bug
If a panel is closed very quickly after opening (can happen if the user accidentally double-taps, for example), the app suddenly becomes unresponsive to further tap/click events. It seems that the backdrop element is left behind, despite the panel being closed.
To Reproduce
Steps to reproduce the behavior:
See CodeSandbox link: https://codesandbox.io/p/sandbox/dazzling-feather-0s7qc6
Tapping the "Open panel normally" shows a normal behaving panel. Tapping "Open panel and break app" will show no panel, but after tapping, no other link will work (i.e., app appears unresponsive).
In essence, the key is
- Start the panel opening
- Very quickly, close the panel (e.g., on the
panelOpenevent). This can be done manually by tapping very quickly on the panel open button, as it's possible to tap on the backdrop while the panel is still sliding open - When the bug happens, the panel is closed, but the app stops responding to any taps or clicks
Expected behavior
The panel should close, but the app should remain responsive
Actual Behavior
The panel closes but the app becomes unresponsive to taps
Additional context
The root cause seems to be that the transitionEnd trigger never fires if the CSS properties are reverted quickly enough. Surprisingly, it's possible to visibly see the animation running when manually tapping quickly to cause the bug.
One possible idea (I'd be happy to raise a PR if you'd like) is to use Element.getAnimations() to see if the transitionEnd callback might not fire: https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
Basically, the panel open/close logic would be updated to set the CSS, then queue up a microtask (or even setTimeout(..., 0) task) which checks if getAnimations returns an active transition. If the check detects no transition and the transitionEnd callback hasn't fired, the callback would then be fired.
As pseudo-code, something would be added at
| panel.onOpen(); |
function panelTransitionEnd() {
transitionEndTarget.transitionEnd(...);
// NEW: handle case where transitionEnd is not called
queueMicroTask(() => {
// TODO more accurately detect transition animations
if (transitionEndTarget[0] && transitionEndTarget[0].getAnimations().length == 0) {
transitionEndTarget.trigger('animationend'); // TODO is this the right way to trigger this?
}
}
if (animate) {
...
panelTransitionEnd();
$el.removeClass('panel-out not-animated').addClass('panel-in');
panel.onOpen();
} else {
...
}