Remove tags when pressing backspace
This commit is contained in:
parent
237fa10415
commit
86b3b62e65
1 changed files with 8 additions and 0 deletions
|
|
@ -152,6 +152,14 @@ const TagInput: React.FC<TagInputProps> = ({
|
|||
event.preventDefault();
|
||||
addNewTag(inputValue.trim());
|
||||
}
|
||||
} else if (event.key === 'Backspace') {
|
||||
// Remove the last tag if input is empty and there are tags
|
||||
if (inputValue === '' && tags.length > 0) {
|
||||
event.preventDefault();
|
||||
const updatedTags = tags.slice(0, -1);
|
||||
setTags(updatedTags);
|
||||
onTagsChange(updatedTags);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue