From 454eee3d19235c3c331ff26d8f10a35f8b4a6c12 Mon Sep 17 00:00:00 2001 From: tombogle Date: Mon, 18 Sep 2023 16:14:27 -0400 Subject: [PATCH] #401: Prevented start and end chapters from being out of order --- .../run-basic-checks-dialog/book-selection.component.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/run-basic-checks-dialog/book-selection.component.tsx b/src/renderer/components/run-basic-checks-dialog/book-selection.component.tsx index 29c37c050d..96ee3c9ce3 100644 --- a/src/renderer/components/run-basic-checks-dialog/book-selection.component.tsx +++ b/src/renderer/components/run-basic-checks-dialog/book-selection.component.tsx @@ -40,11 +40,15 @@ export default function BookSelection() { const [endChapter, setEndChapter] = useState(chapterCount); const onSelectChangeStartChapter = (_event: SyntheticEvent, value: unknown) => { - setStartChapter((value as ChapterNumberOption).chapterNum); + const newStartChapterNum = (value as ChapterNumberOption).chapterNum; + setStartChapter(newStartChapterNum); + if (newStartChapterNum > endChapter) setEndChapter(newStartChapterNum); }; const onSelectChangeEndChapter = (_event: SyntheticEvent, value: unknown) => { - setEndChapter((value as ChapterNumberOption).chapterNum); + const newEndChapterNum = (value as ChapterNumberOption).chapterNum; + setEndChapter(newEndChapterNum); + if (newEndChapterNum < startChapter) setStartChapter(newEndChapterNum); }; return (