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

change event not firing on email input in React 16 #816

Closed
chodorowicz opened this issue Oct 26, 2017 · 8 comments
Closed

change event not firing on email input in React 16 #816

chodorowicz opened this issue Oct 26, 2017 · 8 comments
Labels
browser: electron pkg/driver This is due to an issue in the packages/driver directory
Milestone

Comments

@chodorowicz
Copy link

chodorowicz commented Oct 26, 2017

  • Operating System: MacOS
  • Cypress Version: 1.0.2
  • Browser Version: Electron / Chrome 61

Is this a Feature or Bug?

Bug

Current behavior:

When running test via headless Electron change event is not fired for email type input. For text input it works correctly. Also text and input work correctly in standard Chrome.

Desired behavior:

Cypress should fire change event.

How to reproduce:

Run test cypress run on following app: https://stackblitz.com/edit/react-eadssh?file=index.js (need to export it and run locally, embedding doesn't seem to work)

import React, { Component } from 'react';
import { render } from 'react-dom';

class App extends Component {
  state = {
    inputValue: '',
    message: ''
  };

  handleChange = (event) => {
    this.setState({ 
      inputValue: event.currentTarget.value,
    });
  }

  handleSubmit = (event) => {
    event.preventDefault();
    this.setState({
      message: this.state.inputValue === ''
        ? 'Error'
        : 'All good'
    });
  }

  render() {
    return (
      <div>
        input value: {this.state.inputValue}
        <form onSubmit={this.handleSubmit}>
          <input onChange={this.handleChange} value={this.state.inputValue} id="input" type="email" />
          <button>submit</button>
        </form>
        {this.state.message}
      </div>
    );
  }
}

render(<App />, document.getElementById('root'));

Test code:

describe('app', () => {
  it('should work with input email type', () => {
    cy.visit('http://localhost:3000/');
    cy.get('#input').type('user@example.com');
    cy.contains('submit').click();
    cy.contains('All good');
  });
});

Additional Info (images, stack traces, etc)

related tickets:

failing with input type email
input-email

all good with text input type
input-text

@ghost
Copy link

ghost commented Oct 26, 2017

Downgrading to 1.0.1 solved the issue for me.

@chodorowicz
Copy link
Author

For me with 1.0.1 it doesn't work at all, even in GUI Chrome 61. 1.0.2 was supposed to fix issues with type not firing change events, so it makes sense it doesn't work for me at all.

@brian-mann
Copy link
Member

brian-mann commented Oct 26, 2017

I'll take a look at this / fix it and we'll release 1.0.3.

We added a bunch of react tests in 1.0.2 (you all can look at the code) and we run our driver tests in both Electron and Chrome, so I'm curious how this could have gotten missed.

Appreciate you all creating a reproducible example.

The new tests for react 16 are here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/test/cypress/integration/e2e/react-16_spec.coffee

This uses an html fixture here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/test/cypress/fixtures/react-16.html

@jennifer-shehane jennifer-shehane added browser: electron pkg/driver This is due to an issue in the packages/driver directory stage: needs investigating Someone from Cypress needs to look at this labels Oct 26, 2017
@jennifer-shehane
Copy link
Member

We are also experiencing this issue within our own Dashboard Service project which uses React 15 on Cypress version 1.0.2.

Failing, reproducible spec here: https://github.com/cypress-io/cypress-dashboard/blob/develop/cypress/integration/users_spec.coffee#L266

@jennifer-shehane jennifer-shehane added stage: ready for work The issue is reproducible and in scope and removed stage: needs investigating Someone from Cypress needs to look at this labels Oct 26, 2017
@chodorowicz
Copy link
Author

@brian-mann Thanks for the answer! What would be a good reproducible example? I've pasted code and test samples? Should I fork the repo and add failing test case?

@Fjoggs
Copy link

Fjoggs commented Oct 27, 2017

I left a comment on this issue on the already closed issue that supposedly solved it, but didn't receive a response. I'm not too familiar with github issues, so I guess I should have just opened a new one? :)

Anyway, I have the same problem, using React 16 and Cypress 1.0.2.
Event's aren't firing for input type="number" using Electron.

@brian-mann
Copy link
Member

Fixed in 1.0.3.

@chodorowicz
Copy link
Author

Great, thank you 🙇

@jennifer-shehane jennifer-shehane removed the stage: ready for work The issue is reproducible and in scope label Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser: electron pkg/driver This is due to an issue in the packages/driver directory
Projects
None yet
Development

No branches or pull requests

4 participants