-
Notifications
You must be signed in to change notification settings - Fork 1.4k
chore(eslint): add warning when using async preventDefault() #7723
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
base: main
Are you sure you want to change the base?
chore(eslint): add warning when using async preventDefault() #7723
Conversation
|
commit: |
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
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.
Really good idea 🔥 Thanks a lot @Shane-Donlon!
}, | ||
messages: { | ||
noAsyncPreventDefault: | ||
'This is an asynchronous function and does not support preventDefault. \nUse preventDefault attributes instead', |
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.
Can you add a link to the docs? Also I think this should suggest the use of sync$
too. WDYT?
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.
Thanks Maiieul, I think it's a great idea to include sync$
also
Is this a more agreeable message?
This is an asynchronous function and does not support preventDefault.
Use sync$ or prevent:default attributes instead.
Documentation: https://qwik.dev/docs/components/events/#preventdefault--stoppropagation
sync$: https://qwik.dev/docs/cookbook/sync-events/

Once agreed I'll commit and push up the message to avoid too many commits for editing the message.
Follow-up question:
Is a changeset needed for this?
What is it?
See also [🐞] onSubmit$ form handler not preventing default #7718
Description
Hey guys,
Feedback welcome - but thought I'd propose this as an idea.
While the knowledge exists in the documentation, the goal here is to prompt Developers that this is not a bug and to search the docs or to ask within Discord.
This does exclude
sync$((e)=>{e.preventDefault()}
functions, and I did add this as a warning over error just in case there was something else I wasn't considering, and wouldn't result in breaking any builds.Checklist