Skip to content

Commit 7787685

Browse files
authored
fix: HOTFIX useHistory currentIndex more than MAX_HISTORY_LENGTH cause replace fail (#8819)
fix: useHistory currentIndex more than MAX_HISTORY_LENGTH cause replace fail
1 parent 74b1f73 commit 7787685

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

gui/src/hooks/useInputHistory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function useInputHistory(historyKey: string) {
5454
return;
5555
}
5656

57-
setCurrentIndex(inputHistory.length + 1);
57+
setCurrentIndex(Math.min(inputHistory.length + 1, MAX_HISTORY_LENGTH));
5858
setInputHistory((prev) => {
5959
return [...prev, inputValue].slice(-MAX_HISTORY_LENGTH);
6060
});

0 commit comments

Comments
 (0)