Skip to content

Commit

Permalink
Add a regression test for #12200 (#12242)
Browse files Browse the repository at this point in the history
* fix selectedIndex in postMountWrapper in ReactDOMFiberSelected

* comment in ReactDomFiberSelect in postMountWrapper for selectedIndex fix

* test for selectedIndex fix

* set boolean value for multiple

* Revert the fix which has been fixed on master
  • Loading branch information
GarethSmall authored and gaearon committed Aug 3, 2018
1 parent 2d0356a commit 75491a8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMSelect-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,4 +792,20 @@ describe('ReactDOMSelect', () => {

document.body.removeChild(container);
});

it('should not select first option by default when multiple is set and no defaultValue is set', () => {
const stub = (
<select multiple={true} onChange={noop}>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
</select>
);
const container = document.createElement('div');
const node = ReactDOM.render(stub, container);

expect(node.options[0].selected).toBe(false); // a
expect(node.options[1].selected).toBe(false); // b
expect(node.options[2].selected).toBe(false); // c
});
});

0 comments on commit 75491a8

Please sign in to comment.