diff --git a/app/javascript/dashboard/components-next/input/DurationInput.vue b/app/javascript/dashboard/components-next/input/DurationInput.vue index b0597648a..7b82373f5 100644 --- a/app/javascript/dashboard/components-next/input/DurationInput.vue +++ b/app/javascript/dashboard/components-next/input/DurationInput.vue @@ -46,12 +46,16 @@ const transformedValue = computed({ duration.value = null; return; } - let minuteValue = convertToMinutes(newValue); - - duration.value = Math.min(Math.max(minuteValue, props.min), props.max); + duration.value = convertToMinutes(newValue); }, }); +const normalizeDuration = () => { + if (duration.value == null) return; + + duration.value = Math.min(Math.max(duration.value, props.min), props.max); +}; + // when unit is changed set the nearest value to that unit // so if the minute is set to 900, and the user changes the unit to "days" // the transformed value will show 0, but the real value will still be 900 @@ -72,6 +76,8 @@ watch(unit, () => { :disabled="disabled" :placeholder="t('DURATION_INPUT.PLACEHOLDER')" class="flex-grow w-full disabled:" + @blur="normalizeDuration" + @keydown.enter="normalizeDuration" />