From 297ddce5fba1a8788301de39636e9907cc13ee32 Mon Sep 17 00:00:00 2001 From: Xiao Hanyu Date: Thu, 11 Apr 2024 21:58:29 +0800 Subject: [PATCH] [@mantine/core] TagsInput: Fix incorrect IME keyboard input handling 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: https://github.com/mantinedev/mantine/pull/4947 --- .../@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)); }