Skip to content

Commit 2db86ad

Browse files
committed
feat: Changed how tab changes on adding and deleting elements
1 parent b3409c9 commit 2db86ad

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/Form.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export const Form: React.FC<FormProps> = props => {
112112

113113
setSections(newTabs);
114114
setValue([...value]);
115+
onChangeTab(currentTab + 1)
115116
}
116117

117118
const removeCurrentSection = () => {
@@ -121,7 +122,7 @@ export const Form: React.FC<FormProps> = props => {
121122

122123
setSections(newTabs);
123124
setValue([...value]);
124-
onChangeTab(Math.max(currentTab - 1, 0))
125+
onChangeTab(Math.min(currentTab, sections.length - 2));
125126
}
126127

127128
return (

0 commit comments

Comments
 (0)