Remove tags when pressing backspace

This commit is contained in:
Chris Veleris 2025-07-31 17:50:44 +03:00 committed by Chris
parent 237fa10415
commit 86b3b62e65

View file

@ -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);
}
}
};