Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added ref support for picker/datepicker components #69

Merged
merged 8 commits into from
Oct 25, 2021
Merged
Prev Previous commit
added focus/blur support to picker useeffect
Miguel Caballero committed Oct 21, 2021
commit c35fe5507ed710ff7156b117acf1791d3a11f318
16 changes: 11 additions & 5 deletions src/components/Picker.tsx
Original file line number Diff line number Diff line change
@@ -112,14 +112,20 @@ const Picker = forwardRef(
};

useEffect(() => {
if (show && onOpen) {
onOpen();
if (show) {
if (isAndroid) {
androidPickerRef.current?.focus();
}
onOpen && onOpen();
}

if (!show && onClose) {
onClose();
if (!show) {
if (isAndroid) {
androidPickerRef.current?.blur();
}
onClose && onClose();
}
// Only execute
// Only execute when show changes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

}, [show]);

const togglePicker = () => {