From 2dc0e3973c775b3f3fcacece9b33c442eb95ffef Mon Sep 17 00:00:00 2001 From: Xiao Hanyu Date: Sun, 31 Mar 2024 20:10:24 +0800 Subject: [PATCH] [@mantine/core] TagsInput: Fix incorrect IME keyboard input handling for `Backspace` (#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. --- .../@mantine/core/src/components/TagsInput/TagsInput.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/@mantine/core/src/components/TagsInput/TagsInput.tsx b/packages/@mantine/core/src/components/TagsInput/TagsInput.tsx index 39a22c6c5ef..ed6647d692a 100644 --- a/packages/@mantine/core/src/components/TagsInput/TagsInput.tsx +++ b/packages/@mantine/core/src/components/TagsInput/TagsInput.tsx @@ -277,7 +277,12 @@ export const TagsInput = factory((_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)); }