mirror of
https://github.com/OFFIS-ESC/constellation-analyzer
synced 2026-01-27 07:43:41 +00:00
Fix duplicate label selection bug in AutocompleteLabelSelector
When attempting to create a label that already exists, the component would add it to the selected labels without checking if it was already selected, causing duplicate entries. Now checks if the label is already selected before adding it. Fixes issue where creating labels via label select allows duplicate labels if the label is already assigned.
This commit is contained in:
parent
2c91320bb7
commit
d17702452d
1 changed files with 4 additions and 2 deletions
|
|
@ -99,8 +99,10 @@ const AutocompleteLabelSelector = ({ value, onChange, scope }: Props) => {
|
||||||
|
|
||||||
// Check if ID already exists
|
// Check if ID already exists
|
||||||
if (labels.some((l) => l.id === id)) {
|
if (labels.some((l) => l.id === id)) {
|
||||||
// If label already exists, just select it
|
// If label already exists, just select it (but only if not already selected)
|
||||||
|
if (!value.includes(id)) {
|
||||||
onChange([...value, id]);
|
onChange([...value, id]);
|
||||||
|
}
|
||||||
setInputValue('');
|
setInputValue('');
|
||||||
setIsOpen(false);
|
setIsOpen(false);
|
||||||
setHighlightedIndex(0);
|
setHighlightedIndex(0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue