-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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(qwikloader): stopPropagation for any async handlers #6123
Conversation
sync$ may not be async function and e.stopPropagation() won't work unless it's fired immediately
ok so this really should fix this problem if you see here only the first sync fn with e.stopPropagation() will make it work correctly |
this fix wasn't the fix I'm looking into qwikloader |
this might be a browser bug or most likely the cancelBubble only happens because it finishes propagation so after setTimeout the event is reset. we have to run stopPropagation after each async action to maintain the correct state // Add a click event listener to the document body
document.body.addEventListener('click', function(e) {
// Stop propagation
e.stopPropagation();
// Log cancelBubble value immediately after stopping propagation
console.log('Immediate cancelBubble:', e.cancelBubble);
// Set a timeout
setTimeout(function() {
// Log cancelBubble value after the timeout
console.log('After setTimeout cancelBubble:', e.cancelBubble);
// e.cancelBubble <--- should be true but it's false
}, 1000);
}); |
fix multiple ways to stopPropagation
a1237da
to
c19e9ad
Compare
LGTM 🙌 . Merging |
} | ||
// forcing async with await resets ev.cancelBubble to false | ||
if (cancelBubble) { | ||
ev.stopPropagation(); |
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.
Shouldn't this be called before awaiting?
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.
Shouldn't this be called before awaiting?
Ah yes, I don't think we want any possible delay here, so something like:
const cancelBubble = ev.cancelBubble;
if (cancelBubble) {
ev.stopPropagation();
}
if (isPromise(results)) {
await results;
}
does that look right @wmertens ? If so happy to make another PR
sync$ may not be async function and e.stopPropagation() won't work unless it's fired immediately
fixes #5322
used this repo with the fix in a custom qwik loader
https://github.com/PatrickJS/bug-qwik-loader-stopPropagation