Skip to content

Commit 70d32e2

Browse files
authored
Close Picker dropdown when disabled (47) (#789)
* Close Picker dropdown when disabled * Surroud with if condition
1 parent 091c136 commit 70d32e2

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/core/src/components/Picker/dropdown/DropDownPicker.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const DropDownPicker: React.FC<
3737
dropDownBorderWidth = 1,
3838
dropDownBorderRadius = 8,
3939
children: childrenProp,
40+
disabled,
4041
...rest
4142
}) => {
4243
const [pickerVisible, setPickerVisible] = React.useState(false);
@@ -83,6 +84,12 @@ const DropDownPicker: React.FC<
8384
}
8485
}, [pickerVisible, autoDismissKeyboard]);
8586

87+
React.useEffect(() => {
88+
if (disabled) {
89+
setPickerVisible(false);
90+
}
91+
}, [disabled]);
92+
8693
return (
8794
<PickerInputContainer
8895
testID="dropdown-picker"
@@ -92,6 +99,7 @@ const DropDownPicker: React.FC<
9299
options={options}
93100
onPress={() => setPickerVisible(!pickerVisible)}
94101
zIndex={pickerVisible ? 100 : undefined} // Guarantees drop down is rendered above all sibling components
102+
disabled={disabled}
95103
{...rest}
96104
>
97105
<DropDownPickerComponent

0 commit comments

Comments
 (0)