iOS disable keyboard input for mode="time"

Abierto
#852 3 comentarios 3 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
38/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript, objective-c, react-native
Área
frontend, mobile

Línea de trabajo

The proposed change targets ios/RNDateTimePicker.m; read its event registration and date picker responder handling first. The report says to resign the picker’s first responder when editing begins, preventing keyboard input in mode="time"; verify the behavior with the reported modal date picker and ensure normal time selection still works.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @react-native-community/[email protected] 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.

Lenguaje dominante
JavaScript
Estrellas
2.9k
Forks
459
Merge medio
4 d 16 h
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de react-native-datetimepicker/datetimepicker

Todos los issues de react-native-datetimepicker/datetimepicker

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.