Populate interval inputs with zero if interval is specified
This commit is contained in:
parent
5ee1fa60db
commit
d068782596
@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from "preact/hooks";
|
||||
import { useCallback, useEffect, useState } from "preact/hooks";
|
||||
import { useReminder } from "./ReminderContext";
|
||||
|
||||
function divmod(a: number, b: number) {
|
||||
@ -45,6 +45,10 @@ export const IntervalSelector = ({
|
||||
}
|
||||
}, [seconds, minutes, hours, days, months]);
|
||||
|
||||
const placeholder = useCallback(() => {
|
||||
return seconds || minutes || hours || days || months ? "0" : "";
|
||||
}, [seconds, minutes, hours, days, months]);
|
||||
|
||||
return (
|
||||
<div class="control intervalSelector">
|
||||
<div class="input interval-group">
|
||||
@ -59,7 +63,7 @@ export const IntervalSelector = ({
|
||||
name="interval_months"
|
||||
maxlength={2}
|
||||
placeholder=""
|
||||
value={months || ""}
|
||||
value={months || placeholder()}
|
||||
onInput={(ev) => {
|
||||
setMonths(parseInt(ev.currentTarget.value));
|
||||
}}
|
||||
@ -75,7 +79,7 @@ export const IntervalSelector = ({
|
||||
name="interval_days"
|
||||
maxlength={4}
|
||||
placeholder=""
|
||||
value={days || ""}
|
||||
value={days || placeholder()}
|
||||
onInput={(ev) => {
|
||||
setDays(parseInt(ev.currentTarget.value));
|
||||
}}
|
||||
@ -93,7 +97,7 @@ export const IntervalSelector = ({
|
||||
name="interval_hours"
|
||||
maxlength={2}
|
||||
placeholder="HH"
|
||||
value={hours || ""}
|
||||
value={hours || placeholder()}
|
||||
onInput={(ev) => {
|
||||
setHours(parseInt(ev.currentTarget.value));
|
||||
}}
|
||||
@ -109,7 +113,7 @@ export const IntervalSelector = ({
|
||||
name="interval_minutes"
|
||||
maxlength={2}
|
||||
placeholder="MM"
|
||||
value={minutes || ""}
|
||||
value={minutes || placeholder()}
|
||||
onInput={(ev) => {
|
||||
setMinutes(parseInt(ev.currentTarget.value));
|
||||
}}
|
||||
@ -125,7 +129,7 @@ export const IntervalSelector = ({
|
||||
name="interval_seconds"
|
||||
maxlength={2}
|
||||
placeholder="SS"
|
||||
value={seconds || ""}
|
||||
value={seconds || placeholder()}
|
||||
onInput={(ev) => {
|
||||
setSeconds(parseInt(ev.currentTarget.value));
|
||||
}}
|
||||
|
Loading…
Reference in New Issue
Block a user