iOS disable keyboard input for mode="time"
enagorny opened this issue Β· comments
Hi! π
Firstly, thanks for your work on this project! π
Today I used patch-package to patch @react-native-community/datetimepicker@7.2.0
for the project I'm working on.
This disables the keyboard input on the mode="time" which many of our users thought is a bug :-/ and this doesn't play well with the https://github.com/mmazzarolo/react-native-modal-datetime-picker
Here is the diff that solved my problem:
diff --git a/node_modules/@react-native-community/datetimepicker/ios/RNDateTimePicker.m b/node_modules/@react-native-community/datetimepicker/ios/RNDateTimePicker.m
index 9c73c8e..efaa23f 100644
--- a/node_modules/@react-native-community/datetimepicker/ios/RNDateTimePicker.m
+++ b/node_modules/@react-native-community/datetimepicker/ios/RNDateTimePicker.m
@@ -26,9 +26,9 @@
#ifndef RCT_NEW_ARCH_ENABLED
// somehow, with Fabric, the callbacks are executed here as well as in RNDateTimePickerComponentView
// so do not register it with Fabric, to avoid potential problems
- [self addTarget:self action:@selector(didChange)
- forControlEvents:UIControlEventValueChanged];
+ [self addTarget:self action:@selector(didChange) forControlEvents:UIControlEventValueChanged];
[self addTarget:self action:@selector(onDismiss:) forControlEvents:UIControlEventEditingDidEnd];
+ [self addTarget:self action:@selector(handleDatePickerTap) forControlEvents:UIControlEventEditingDidBegin];
#endif
_reactMinuteInterval = 1;
@@ -52,6 +52,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
}
}
+- (void)handleDatePickerTap
+{
+ [self resignFirstResponder];
+}
+
- (void)setDatePickerMode:(UIDatePickerMode)datePickerMode
{
[super setDatePickerMode:datePickerMode];
This issue body was partially generated by patch-package.