Skip to content

Changing other input field values clears SELECT values  #786

@vkallore

Description

@vkallore

Thank you so much for this plugin. I'm facing an issue with this.

I have a form with different input fields. Select works as expected, but on changing of input field value, SELECT field values get cleared. What could be the reason? I'm having different onChange listeners for SELECT and INPUT.

Example code with issue is given below. I'm not sure how to create a JSFiddle with React Select. Sorry for that.

/* eslint react/prop-types: 0 */

import React from 'react';
import ReactDOM from 'react-dom';
import Select from 'react-select';

require('react-select/dist/react-select.min.css');

var options = [
    { value: 'one', label: 'One' },
    { value: 'two', label: 'Two' }
];

var Hello = React.createClass({

  handleChange: function(date) {
    this.setState({
      startDate: date
    });
  },
  render: function() {
    return (
      <div>
        <input 
          className="form-control"
          defaultValue=''
          name="postal_code"
          type="text"
          onChange={this.handleChange} />
        <Select
          name="city"
          options={options}
          onChange={onSelectChange} />
      </div>);
  }
});
function onSelectChange(val) {
  console.log("Selected: " + val);
}
ReactDOM.render(
  <Hello />,
  document.getElementById('userProfileDetails')
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions