fix: HOTFIX useHistory currentIndex more than MAX_HISTORY_LENGTH cause replace fail (#8819)
fix: useHistory currentIndex more than MAX_HISTORY_LENGTH cause replace fail
This commit is contained in:
parent
74b1f73a87
commit
7787685f12
1 changed files with 1 additions and 1 deletions
|
|
@ -54,7 +54,7 @@ export function useInputHistory(historyKey: string) {
|
|||
return;
|
||||
}
|
||||
|
||||
setCurrentIndex(inputHistory.length + 1);
|
||||
setCurrentIndex(Math.min(inputHistory.length + 1, MAX_HISTORY_LENGTH));
|
||||
setInputHistory((prev) => {
|
||||
return [...prev, inputValue].slice(-MAX_HISTORY_LENGTH);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue