import FixtureSet from '../../FixtureSet'; import TestCase from '../../TestCase'; const React = window.React; const ReactDOM = window.ReactDOM; class SelectFixture extends React.Component { state = {value: ''}; _nestedDOMNode = null; _singleFormDOMNode = null; _multipleFormDOMNode = null; onChange = event => { this.setState({value: event.target.value}); }; resetSingleOptionForm = event => { event.preventDefault(); this._singleFormDOMNode.reset(); }; resetMultipleOptionForm = event => { event.preventDefault(); this._multipleFormDOMNode.reset(); }; componentDidMount() { this._renderNestedSelect(); } componentDidUpdate() { this._renderNestedSelect(); } _renderNestedSelect() { ReactDOM.render( , this._nestedDOMNode ); } render() { return (
Controlled Value: {this.state.value}
Uncontrolled
Controlled in nested subtree
(this._nestedDOMNode = node)} /> This should synchronize in both direction with the "Controlled".
  • Open the select
  • Select "1"
  • Attempt to reselect "Please select an item"
  • The initial picked option should be "Please select an item", however it should not be a selectable option.
    The initial picked option value should "0": the first non-disabled option.
  • Open the select
  • Select "baz" or "foo"
  • Click the "Reset" button
  • The select should be reset to the initial value, "bar"
    (this._singleFormDOMNode = n)}>
  • Select any combination of options
  • Click the "Reset" button
  • The select should be reset to the initial values "foo" and "baz"
    (this._multipleFormDOMNode = n)}>
    First selected option should be visible
  • Select any option
  • Option should be set
    No options should be selected.

    Notes: This happens if size is assigned after options are selected. The select element picks the first item by default, then it is expanded to show more options when{' '} size is assigned, preserving the default selection.

    This was introduced in React 16.0.0 when options were added before select attribute assignment.

    ); } } export default SelectFixture;