From 487c8560d2845b0708c2636a4151c0fbbccb631b Mon Sep 17 00:00:00 2001 From: Alexandru Mariuti Date: Thu, 30 Jan 2025 18:31:25 +0100 Subject: [PATCH] fix: on changed for each field --- lib/src/components/time_picker.dart | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/src/components/time_picker.dart b/lib/src/components/time_picker.dart index f64f5e4..9b436f2 100644 --- a/lib/src/components/time_picker.dart +++ b/lib/src/components/time_picker.dart @@ -711,9 +711,9 @@ class _ShadTimePickerState extends State { decoration: effectiveFieldDecoration, enabled: widget.enabled, onChanged: (v) { - if (v.length == 2) { + if (v.isNotEmpty) { controller.setHour(int.tryParse(v)); - if (effectiveJumpToNextField) { + if (v.length == 2 && effectiveJumpToNextField) { focusNodes[1].requestFocus(); } } @@ -732,9 +732,9 @@ class _ShadTimePickerState extends State { decoration: effectiveFieldDecoration, enabled: widget.enabled, onChanged: (v) { - if (v.length == 2) { + if (v.isNotEmpty) { controller.setMinute(int.tryParse(v)); - if (effectiveJumpToNextField) { + if (v.length == 2 && effectiveJumpToNextField) { focusNodes[2].requestFocus(); } } @@ -753,9 +753,10 @@ class _ShadTimePickerState extends State { decoration: effectiveFieldDecoration, enabled: widget.enabled, onChanged: (v) { - if (v.length == 2) { + if (v.isNotEmpty) { controller.setSecond(int.tryParse(v)); - if (effectiveJumpToNextField && + if (v.length == 2 && + effectiveJumpToNextField && widget.variant == ShadTimePickerVariant.period) { periodFocusNode.requestFocus(); }