-
Notifications
You must be signed in to change notification settings - Fork 263
Triggering a click on a submit button does not submit the parent form #171
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
Comments
Thanks you opening this. I would really like to fix this. I have had this same problem for many years and the way I work around is it by doing Interestingly enough if you remove
Which can probably fixed with a manual We use the same logic for both VTU 1 and 2 for the trigger stuff. I am sure this is a bug in VTU. I will enlist professional help from the rest of the Vue team on this one 💪 |
That error is logged because the first I'll try to do some debugging later this week, if I find anything I'll update this issue. |
I figured the jsdom error was related to not preventing the default submission. I guess how we handle I also tried this in a browser with VTU and it didn't work there either, so it is definitely not a jsdom error. I would very much like to solve this error - lmk if you have any other ideas or suspicions. |
Definitely, the default behaviour of a form submission is not supported by
I don't think so, from what I can tell it's working exactly as expected. If we remove I think I can narrow this down further by running the same test but without |
Okay, I've figured it out, and this isn't a bug after all. The problem was that If I run the following in my browser (Chrome) console: const el = document.createElement('div')
el.innerHTML = '<form><button></button></form>'
const button = el.querySelector('button')
button.dispatchEvent(new MouseEvent('click')) I get an error:
If I instead pass @lmiller1990 I'd like to add some clarification to the docs, but it appears they're in another repo? Is that because Vuepress is still using Vue 2? |
Ahhhh that is very interesting. Makes sense! Yep, the docs are in another repo because Vuepress only works with Vue 2. We will move to Vitepress soon, maybe. If you would like to make a PR in the docs repo that would be great! There is a page for forms specifically: https://vuejs.github.io/vue-test-utils-next-docs/guide/forms.html. The repo is here: https://github.com/vuejs/vue-test-utils-next-docs |
I think I might have a similar issue: I was trying to attach a component that is using Vuetify to the DOM (using happy-dom), but still the click does not submit the form for me.
Using |
@maconic Can you try with jsdom? happy-dom has several issues, I wouldn't be surprised if it's the cause of your issue. |
@cexbrayat Makes no difference sadly (except for that fetch API is not defined in JSDOM, seems to work with happy-dom). I will try to create an example repo with this, if thats OK? |
@cexbrayat turns out it WAS an issue with happy-dom! Works great in the demo project (https://github.com/maconic/vue-vuetify-demo-project) with jsdom. To bad jsdom does not provide mocks for fetch api :( |
Thanks for letting us know 👍 I think you can install |
I opened this bug in
vue-test-utils
first: vuejs/vue-test-utils#1635And then I created a minimal reproduction using
[email protected]
and@vue/[email protected]
: https://github.com/vvanpo/minimal-repros/tree/master/vue-test-utilsThe test looks as follows:
Both the pure
jsdom
examples pass, and give the correct behaviour that browsers also give. But the@vue/test-utils
example fails, even though it's using the same component and essentially doing the exact same thing.The text was updated successfully, but these errors were encountered: