Skip to content

Commit

Permalink
fix: stale activeIndex values
Browse files Browse the repository at this point in the history
  • Loading branch information
Vali-98 committed Dec 1, 2024
1 parent eec1551 commit 0e0106d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion constants/API/APIManagerState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export namespace APIState {
set((state) => ({
...state,
values: values,
activeIndex: values.length - 1,
}))
},

Expand All @@ -58,8 +59,12 @@ export namespace APIState {
},
removeValue: (index) => {
const values = get().values
let activeIndex = get().activeIndex
if (index === activeIndex) {
activeIndex = -1
}
values.splice(index, 1)
set((state) => ({ ...state, values: values }))
set((state) => ({ ...state, values: values, activeIndex: activeIndex }))
},
removeTemplate: (index) => {
const templates = get().customTemplates
Expand Down

0 comments on commit 0e0106d

Please sign in to comment.