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` key (#6011)

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.

Ref PR: #4947
  • Loading branch information
xiaohanyu authored Apr 11, 2024
1 parent bef8a16 commit 297ddce
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 297ddce

Please sign in to comment.