Open pixelwhip opened 7 years ago
I would love to know how to do this as well.
Hi!
I don't have time to implement it right now, but I would love to review a PR. Keep in mind that you should need to handle forms with several pickers.
I would absolutely love this too! The existing functionality is not very intuitive
期待这个功能!
Is this still not resolved or accounted for somewhere else? With a form containing multiple pickers, it's very odd to have them all remain open.
with my PR you can now set your options like this (only iOS)
Options for form
getCustomerOptions() {
return {
label: 'Customer',
fields: {
...
gender: {
isCollapsed: this.state.genderIsCollapsed,
nullOption: { value: '', text: 'Form of Address' },
onCollapseChange: this.genderCollapseChange,
},
type: {
isCollapsed: this.state.typeIsCollapsed,
},
...
}
}
...
genderCollapseChange(genderIsCollapsed) {
const validationResult = this.createCustomerFormRef.pureValidate();
this.setState({
currentCustomer: validationResult.value,
genderIsCollapsed,
});
if (newCollapse === false) {
this.setState({
typeIsCollapsed: true,
});
}
}
render() {
return (
...
<Formular
ref={(c) => { this.createCustomerFormRef = c; }}
type={Customer}
value={this.state.currentCustomer}
options={this.getCustomerOptions()}
/>
...
So you can set the collapse state for each Picker and react on collapse change from your component using the form. => you can collapse all other picker or open them or collapse only specific once.
I have a form with multiple enum inputs which create multiple collapsible iOS pickers. Each picker opens when the touchableOpacity is pressed and can be closed in the same manner. I'd like to have a picker collapse automatically when another picker is expanded but figure out how to do it. Is it possible to somehow trigger the collapse programmatically?