Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Reset button also resets sequence generation setup and clears output [PT-187393497] #58

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ const normalAnimationOverride = parseInt((new URLSearchParams(window.location.se
const FastAnimationDelay = isNaN(fastAnimationOverride) ? 250 : fastAnimationOverride;
const NormalAnimationDelay = isNaN(normalAnimationOverride) ? 1000 : normalAnimationOverride;

const defaultLengthLimit = 5;
const defaultDelimiter = " ";
const defaultStartingState = "";
const defaultFastSimulation = false;

type SequenceGroup = {
startingState: string;
startingNode: Node | undefined;
Expand Down Expand Up @@ -69,9 +74,9 @@ const SequenceOutputHeader = ({ group }: { group: SequenceGroup }) => {
};

export const App = () => {
const [lengthLimit, setLengthLimit] = useState<number | undefined>(5);
const [delimiter, setDelimiter] = useState(" ");
const [startingState, setStartingState] = useState("");
const [lengthLimit, setLengthLimit] = useState<number | undefined>(defaultLengthLimit);
const [delimiter, setDelimiter] = useState(defaultDelimiter);
const [startingState, setStartingState] = useState(defaultStartingState);
const [sequenceGroups, setSequenceGroups] = useState<SequenceGroup[]>([]);
const [selectedNodeId, _setSelectedNodeId] = useState<string>();
const [highlightNode, setHighlightNode] = useState<Node>();
Expand Down Expand Up @@ -134,7 +139,7 @@ export const App = () => {
});
const { generate } = useGenerator();
const innerOutputRef = useRef<HTMLDivElement | null>(null);
const [fastSimulation, setFastSimulation] = useState(false);
const [fastSimulation, setFastSimulation] = useState(defaultFastSimulation);
const fastSimulationRef = useRef(false);

const handleDimensionChange = ({width, height}: {width: number, height: number}) => {
Expand Down Expand Up @@ -451,6 +456,11 @@ export const App = () => {

const handleReset = useCallback(() => {
if (confirm("Are you sure you want to reset?\n\nAny changes you have made will be lost.")) {
setLengthLimit(defaultLengthLimit);
setDelimiter(defaultDelimiter);
setStartingState(defaultStartingState);
setSequenceGroups([]);
setFastSimulation(defaultFastSimulation);
setGraph(initialGraph ? {...initialGraph} : {nodes: [], edges: []});
}
}, [initialGraph, setGraph]);
Expand Down
Loading