Skip to content

Commit 5c8dee4

Browse files
authored
Merge pull request #210 from ZFengMo/dev
feat: refactor OperatorSelect to prevent duplicate selections
2 parents 62fc2b7 + ef668d2 commit 5c8dee4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/OperatorSelect.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ export const OperatorSelect: FC<OperatorSelectProps> = ({
7878
}
7979

8080
const add = (operation: OperatorInfo) => {
81-
change([...new Set([...operators, { name: operation.name }])])
81+
if (!operators.some((op) => op.name === operation.name)) {
82+
change([...operators, { name: operation.name }])
83+
} else {
84+
remove(operation)
85+
}
8286
}
8387

8488
const remove = (operation: OperatorInfo) => {

0 commit comments

Comments
 (0)