Skip to content

Commit

Permalink
[@mantine/core] TagsInput: Fix incorrect IME keyboard input handling …
Browse files Browse the repository at this point in the history
…for `Backspace` (mantinedev#6010)

When people use IME to type in CJK words, a `Backspace` key would delete both a
char in the CJK words and the previous tag before this fix.
  • Loading branch information
xiaohanyu committed Mar 31, 2024
1 parent 30a48df commit 2dc0e39
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,12 @@ export const TagsInput = factory<TagsInputFactory>((_props, ref) => {
}
}

if (event.key === 'Backspace' && length === 0 && _value.length > 0) {
if (
event.key === 'Backspace' &&
length === 0 &&
_value.length > 0 &&
!event.nativeEvent.isComposing
) {
onRemove?.(_value[_value.length - 1]);
setValue(_value.slice(0, _value.length - 1));
}
Expand Down

0 comments on commit 2dc0e39

Please sign in to comment.