iOS disable keyboard input for mode="time"

Offen
#852 3 Kommentare 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
38/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
javascript, objective-c, react-native
Bereich
frontend, mobile

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
JavaScript
Sterne
2.9k
Forks
459
Ø Merge
4 T. 16 Std.
Gemergte PRs (30 T.)
5

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus react-native-datetimepicker/datetimepicker

Alle Issues in react-native-datetimepicker/datetimepicker

Ähnliche Issues

Weitere Issues zu JavaScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.