Skip to content

Commit 14a8a29

Browse files
authored
Refactor indexing to display as 1-indexed (#26)
Internally, the function index is 0 indexed, but displays as being 1 indexed. This patch fixes that and also limits the funcIndex to be within range of [1, numFunctions].
1 parent 1eb9715 commit 14a8a29

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

www/main.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,13 @@ function MenuBar(props: MenuBarProps) {
8181
{numFunctions > 1 && <div>
8282
Function <input
8383
type="number"
84-
value={funcIndex}
84+
min="1"
85+
max={numFunctions}
86+
value={funcIndex + 1}
8587
className="ig-w3"
8688
onChange={e => {
87-
const newFuncIndex = Math.max(0, Math.min(numFunctions - 1, parseInt(e.target.value, 10)));
89+
const displayValue = parseInt(e.target.value, 10);
90+
const newFuncIndex = Math.max(0, Math.min(numFunctions - 1, displayValue - 1));
8891
setFuncIndex(isNaN(newFuncIndex) ? 0 : newFuncIndex);
8992
}}
9093
/> / {numFunctions}

0 commit comments

Comments
 (0)