Skip to content

Commit 661fa25

Browse files
committed
prevent seconds update on timepicker when nothing else changes
1 parent d77048a commit 661fa25

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

resources/js/packages/ui/src/Input/TimePickerSimple.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,19 @@ function updateTime(event: Event) {
2727
if (newValue.split(':').length === 2) {
2828
const [hours, minutes] = newValue.split(':');
2929
if (!isNaN(parseInt(hours)) && !isNaN(parseInt(minutes))) {
30-
model.value = getLocalizedDayJs(model.value)
31-
.set('hours', Math.min(parseInt(hours), 23))
32-
.set('minutes', Math.min(parseInt(minutes), 59))
33-
.set('seconds', 0)
34-
.format();
35-
emit('changed', model.value);
30+
const currentTime = getLocalizedDayJs(model.value);
31+
const newHours = Math.min(parseInt(hours), 23);
32+
const newMinutes = Math.min(parseInt(minutes), 59);
33+
34+
// Only update if hours or minutes are different
35+
if (currentTime.hour() !== newHours || currentTime.minute() !== newMinutes) {
36+
model.value = currentTime
37+
.set('hours', newHours)
38+
.set('minutes', newMinutes)
39+
.set('seconds', 0)
40+
.format();
41+
emit('changed', model.value);
42+
}
3643
}
3744
}
3845
// check if input is only numbers

0 commit comments

Comments
 (0)