From 6259f87b59017d3ef698a7d68e8f3fe9084b77bb Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 17 Apr 2024 12:32:26 -0400 Subject: [PATCH 1/3] chore: do not convert to infinite with empty Input --- .../components/CyclePanel.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/renderer/routes/test_sequencer_panel/components/CyclePanel.tsx b/src/renderer/routes/test_sequencer_panel/components/CyclePanel.tsx index f19d9f3c2..546ed9bbd 100644 --- a/src/renderer/routes/test_sequencer_panel/components/CyclePanel.tsx +++ b/src/renderer/routes/test_sequencer_panel/components/CyclePanel.tsx @@ -12,6 +12,7 @@ import { HoverCardContent, HoverCardTrigger, } from "@/renderer/components/ui/hover-card"; +import { useState } from "react"; export function CyclePanel() { const { tree, isLocked } = useDisplayedSequenceState(); @@ -41,6 +42,14 @@ export function CyclePanel() { return null; } + const [value, setValue] = useState(cycleConfig.cycleCount); + const handleChange = (event: React.ChangeEvent) => { + if (event.target.value !== "") { + setCycleCount(Number(event.target.value)); + } + setValue(Number(event.target.value)); + } + return ( @@ -65,10 +74,8 @@ export function CyclePanel() { id="cycle" placeholder="1" disabled={cycleConfig.infinite} - value={cycleConfig.cycleCount} - onChange={(event) => { - setCycleCount(Number(event.target.value)); - }} + value={value} + onChange={handleChange} />
From 591152f7ef4c60ddc81fff927ab1cd00c7ada1c3 Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 17 Apr 2024 12:33:02 -0400 Subject: [PATCH 2/3] chore: formatting --- .../routes/test_sequencer_panel/components/CyclePanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/routes/test_sequencer_panel/components/CyclePanel.tsx b/src/renderer/routes/test_sequencer_panel/components/CyclePanel.tsx index 546ed9bbd..ff89c1940 100644 --- a/src/renderer/routes/test_sequencer_panel/components/CyclePanel.tsx +++ b/src/renderer/routes/test_sequencer_panel/components/CyclePanel.tsx @@ -48,7 +48,7 @@ export function CyclePanel() { setCycleCount(Number(event.target.value)); } setValue(Number(event.target.value)); - } + }; return ( From 1c48c28c570fdfad4470f3c55b47e393a28843ba Mon Sep 17 00:00:00 2001 From: Guillaume Date: Wed, 17 Apr 2024 12:52:45 -0400 Subject: [PATCH 3/3] fix: Eslint error --- .../test_sequencer_panel/components/CyclePanel.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/renderer/routes/test_sequencer_panel/components/CyclePanel.tsx b/src/renderer/routes/test_sequencer_panel/components/CyclePanel.tsx index ff89c1940..2c804c12a 100644 --- a/src/renderer/routes/test_sequencer_panel/components/CyclePanel.tsx +++ b/src/renderer/routes/test_sequencer_panel/components/CyclePanel.tsx @@ -12,7 +12,7 @@ import { HoverCardContent, HoverCardTrigger, } from "@/renderer/components/ui/hover-card"; -import { useState } from "react"; +import { useEffect, useState } from "react"; export function CyclePanel() { const { tree, isLocked } = useDisplayedSequenceState(); @@ -42,7 +42,8 @@ export function CyclePanel() { return null; } - const [value, setValue] = useState(cycleConfig.cycleCount); + const [value, setValue] = useState(1); + const handleChange = (event: React.ChangeEvent) => { if (event.target.value !== "") { setCycleCount(Number(event.target.value)); @@ -50,6 +51,10 @@ export function CyclePanel() { setValue(Number(event.target.value)); }; + useEffect(() => { + setValue(cycleConfig.cycleCount); + }, [cycleConfig.cycleCount]); + return (