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

type('{enter}') doesn't work when only 1 input blocking implicit submission #4495

Closed
aisingoro opened this issue Jun 19, 2019 · 6 comments

Comments

4 participants
@aisingoro
Copy link

commented Jun 19, 2019

Current behavior:

I've already tried:

cy.get('input').eq(0).type('{enter}')

But it doesn't work. I've also tried:

cy.get('input').eq(0).type('{enter}').trigger('input')

And:

cy.get('input').eq(0).type('{enter}').trigger('input').eq(0).
{uparrow},{downarrow},tab()

they're all right.But ENTER isn't.

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Jun 21, 2019

Unfortunately we have to close this issue as there is not enough information to reproduce the problem. We have many tests that {enter} works, so we will need to know what is specific to your application that would make it not work here.

Please provide the HTML you are testing against, the error message that you are seeing, and a reproducible example that we can run locally and we will reopen the issue. 🙏

@jodelasur

This comment has been minimized.

Copy link

commented Jun 26, 2019

I'm also having this issue right now. I uploaded a sample system for you to check. See https://github.com/jodelasur/cypress-issue-4495.

The issue for me is that the submit is not firing. I'm assuming this is because of the 1st "other situation" listed in https://docs.cypress.io/api/commands/type.html#Form-Submission:

Does not submit a form if there are multiple inputs and no submit button.

However, looking at the spec referenced, https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#implicit-submission, it says (with emphasis added):

If the form has no submit button, then the implicit submission mechanism must do nothing if the form has more than one field that blocks implicit submission,

The form in the sample system has two inputs, one text and one hidden. It seems Cypress doesn't submit the form because there are multiple inputs. But per the spec, text input blocks implicit submission, but hidden doesn't. That means there's just one field that blocks implicit submission (not more than one), so the form should still submit.

I think my understanding of this is correct since browsers I've tested with (Chrome, Firefox) submits the form correctly. Also, when I add another text field to the form, that's the time when the browsers don't submit, conforming to the spec.

Hope this gets fixed.

@jennifer-shehane

This comment has been minimized.

Copy link
Member

commented Jun 26, 2019

oh boy.

Yes, I believe your assessment is correct. Also, yes, the form does an implicit submission manually within your example.

I've simplified the HTML example for our testing purposes as shown below - this form should submit when typing {enter} in the input of type text.

<form>
  <input type="text">
  <input type="hidden">
</form>
@Bigdragon13th

This comment has been minimized.

Copy link

commented Jun 29, 2019

The spec is indeed very confusing 🤣

@cypress-bot

This comment has been minimized.

Copy link

commented Jul 9, 2019

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

@cypress-bot

This comment has been minimized.

Copy link

commented Jul 9, 2019

Released in 3.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.