Keep time units upon time entry
Fixes: #26549 Signed-off-by: Hynek Mlnarik <hmlnarik@redhat.com>
This commit is contained in:
parent
0e1f3ec402
commit
0df5452507
1 changed files with 5 additions and 1 deletions
|
@ -60,6 +60,8 @@ export const TimeSelector = ({
|
||||||
}: TimeSelectorProps) => {
|
}: TimeSelectorProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const [lastMultiplier, setLastMultiplier] = useState<number>();
|
||||||
|
|
||||||
const defaultMultiplier = useMemo(
|
const defaultMultiplier = useMemo(
|
||||||
() => allTimes.find((time) => time.unit === units[0])?.multiplier,
|
() => allTimes.find((time) => time.unit === units[0])?.multiplier,
|
||||||
[units],
|
[units],
|
||||||
|
@ -88,9 +90,11 @@ export const TimeSelector = ({
|
||||||
if (value) {
|
if (value) {
|
||||||
setMultiplier(multiplier);
|
setMultiplier(multiplier);
|
||||||
setTimeValue(value / multiplier);
|
setTimeValue(value / multiplier);
|
||||||
|
setLastMultiplier(multiplier);
|
||||||
} else {
|
} else {
|
||||||
setTimeValue(value || "");
|
setTimeValue(value || "");
|
||||||
setMultiplier(defaultMultiplier);
|
setMultiplier(lastMultiplier ?? defaultMultiplier);
|
||||||
|
setLastMultiplier(lastMultiplier ?? defaultMultiplier);
|
||||||
}
|
}
|
||||||
}, [value, defaultMultiplier]);
|
}, [value, defaultMultiplier]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue