Skip to content

Commit

Permalink
fix(select): pass state.value to NativeControl as prop.value (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgr34 authored and Matt Goo committed Mar 18, 2019
1 parent 619d12c commit 09ad132
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export default class Select extends React.Component<SelectProps, SelectState> {
outlined,
onChange,
ref,
value,
/* eslint-enable */
...otherProps
} = this.props;
Expand All @@ -212,6 +213,7 @@ export default class Select extends React.Component<SelectProps, SelectState> {
handleDisabled={this.setDisabled}
onChange={this.onChange}
setRippleCenter={this.setRippleCenter}
value={this.state.value}
{...otherProps}
>
{this.renderOptions()}
Expand Down
9 changes: 9 additions & 0 deletions test/unit/select/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ test('passes classNames to NativeControl through props.nativeControlClassName',
assert.isTrue(wrapper.childAt(0).hasClass(className));
});

test('#NativeControl.value will update with Select.state.value', () => {
const wrapper = shallow<Select>(<Select label='my label' />);
const value = 'value';
wrapper.setState({value});

assert.equal(wrapper.state().value, value);
assert.equal(wrapper.childAt(0).props().value, value);
});

test('#NativeControl.onChange will update state.value', () => {
const wrapper = shallow<Select>(<Select label='my label' />);
const evt = {target: {value: 'orange'}};
Expand Down

0 comments on commit 09ad132

Please sign in to comment.