MultiPicker logic incorrect, when not set selectedValue.
zhang740 opened this issue · comments
SuperEVO commented
If not set selectedValue, is no has event fire when reselect the first item.
core code:
MultiPicker.tsx:
const selectedValue = this.getValue();
const colElements = React.Children.map(children, (col: any, i) => {
return React.cloneElement(col, {
selectedValue: selectedValue[i],
onValueChange: (...args) => this.onValueChange(i, ...args),
});
});
the getValue
implement in MultiPickerMixin.tsx:
getValue() {
const { children, selectedValue } = this.props;
if (selectedValue && selectedValue.length) {
return selectedValue;
} else {
if (!children) {
return [];
}
return React.Children.map(children, (c: any) => {
const cc: any = React.Children.toArray(c.props.children);
return cc && cc[0] && cc[0].props.value;
});
}
},
If not set selectedValue, the result of getValue()
alway equel the first item's value
of picker's children of multipicker.
paranoidjk commented
What's your problem?
Can you give a reproducible demo?
SuperEVO commented
selectedValue is required for MultiPicker.
paranoidjk commented
@zhang740 If so, consider add a dev console warning about requirement props check, eg: https://github.com/react-component/tabs/blob/7f78a1668fb034e9cc85b62d19df4e9ce1c516ee/src/TabBarMixin.js#L38