Skip to content

Commit

Permalink
fix(CascaderSelect): not exist value be removed
Browse files Browse the repository at this point in the history
not exist value  be removed after checked
  • Loading branch information
myronliu347 committed Jul 26, 2019
1 parent 41e9399 commit 2b1dee8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/cascader-select/cascader-select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ export default class CascaderSelect extends Component {

handleChange(value, data, extra) {
const { multiple, changeOnSelect, onChange } = this.props;
const { visible, searchValue } = this.state;
const { visible, searchValue, value: stateValue } = this.state;

const st = {};
if (
Expand All @@ -574,6 +574,11 @@ export default class CascaderSelect extends Component {
) {
this.handleVisibleChange(!visible, 'fromCascader');
}

if (multiple && stateValue && Array.isArray(stateValue)) {
value = [...stateValue.filter(v => !this._v2n[v]), ...value];
}

if (!('value' in this.props)) {
st.value = value;
}
Expand Down
8 changes: 8 additions & 0 deletions test/cascader-select/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,14 @@ describe('CascaderSelect', () => {
value: VALUE,
});
assert(called);
wrapper.setProps({
valueRender: item => item.label,
onChange: (value) => {
assert.deepEqual(value, [VALUE, '2973']);
}
});
const item00 = findItem(0, 0);
ReactTestUtils.Simulate.click(item00);
});
});

Expand Down

0 comments on commit 2b1dee8

Please sign in to comment.