Skip to content

Commit ef668d2

Browse files
committed
feat: refactor OperatorSelect to prevent duplicate selections
The add function in OperatorSelect now checks if the selected operator is already in the list of operators. If it is, the function removes the operator from the list. This prevents duplicate selections in the component.
1 parent 62fc2b7 commit ef668d2

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)