prevent seconds update on timepicker when nothing else changes

This commit is contained in:
Gregor Vostrak
2025-11-12 18:15:59 +01:00
parent 878ac4ab81
commit 306a081a3d

View File

@@ -27,12 +27,19 @@ function updateTime(event: Event) {
if (newValue.split(':').length === 2) { if (newValue.split(':').length === 2) {
const [hours, minutes] = newValue.split(':'); const [hours, minutes] = newValue.split(':');
if (!isNaN(parseInt(hours)) && !isNaN(parseInt(minutes))) { if (!isNaN(parseInt(hours)) && !isNaN(parseInt(minutes))) {
model.value = getLocalizedDayJs(model.value) const currentTime = getLocalizedDayJs(model.value);
.set('hours', Math.min(parseInt(hours), 23)) const newHours = Math.min(parseInt(hours), 23);
.set('minutes', Math.min(parseInt(minutes), 59)) const newMinutes = Math.min(parseInt(minutes), 59);
.set('seconds', 0)
.format(); // Only update if hours or minutes are different
emit('changed', model.value); if (currentTime.hour() !== newHours || currentTime.minute() !== newMinutes) {
model.value = currentTime
.set('hours', newHours)
.set('minutes', newMinutes)
.set('seconds', 0)
.format();
emit('changed', model.value);
}
} }
} }
// check if input is only numbers // check if input is only numbers