We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1e40f3d commit 9a895c3Copy full SHA for 9a895c3
specifyweb/frontend/js_src/lib/components/FormSliders/RecordSelectorFromIds.tsx
@@ -91,13 +91,18 @@ export function RecordSelectorFromIds<SCHEMA extends AnySchema>({
91
};
92
}, [ids, model]);
93
94
- const [index, setIndex] = useTriggerState(defaultIndex ?? ids.length - 1);
+ const [index, setIndex] = useTriggerState(
95
+ Math.max(0, defaultIndex ?? ids.length - 1)
96
+ );
97
React.useEffect(
98
() =>
99
setIndex((index) =>
- typeof newResource === 'object'
- ? rest.totalCount
100
- : Math.min(index, rest.totalCount - 1)
+ Math.max(
101
+ 0,
102
+ typeof newResource === 'object'
103
+ ? rest.totalCount
104
+ : Math.min(index, rest.totalCount - 1)
105
+ )
106
),
107
[newResource, rest.totalCount]
108
);
0 commit comments