Skip to content
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

Implicit form submission should work when the submit button is not nested in the form, but is associated #21163

Closed
skvale opened this issue Apr 21, 2022 · 2 comments · Fixed by #21279
Labels
pkg/driver This is due to an issue in the packages/driver directory

Comments

@skvale
Copy link
Contributor

skvale commented Apr 21, 2022

Current behavior

When there is a submit button outside of the form, but associated to the form by the form attribute

someInput.type('{enter}')

does not submit the form

I'm assuming this is because Cypress is searching for the buttons with

form.find('input, button')

Instead of searching for every submit button/input and testing if it's nested or associated by the form attribute

My submit button is not a child of the form, but it looks like

<form id="my-form-id" onSubmit={function(e) { console.log('submitted'); e.preventDefault() }}>
  <input type="text" />
</form>
<button form="my-form-id" type="submit">Save</button>

Desired behavior

Cypress should implicitly submit the form on enter in a text field

Test code to reproduce

<form 
  id="my-form-id" 
  onSubmit={function(e) { console.log('submitted'); e.preventDefault() }}>
    <input type="text" />
</form>

<button 
  form="my-form-id" 
  type="submit">
    Save
</button>

Cypress Version

9.5.3

Other

No response

@davidmunechika davidmunechika added the pkg/driver This is due to an issue in the packages/driver directory label Apr 21, 2022
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: backlog labels Apr 30, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 5, 2022

The code for this is done in cypress-io/cypress#21279, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot removed the stage: needs review The PR code is done & tested, needs review label May 5, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 9, 2022

Released in 9.6.1.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v9.6.1, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators May 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pkg/driver This is due to an issue in the packages/driver directory
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants