From f64140f01de6543e9c500ace7c2f29c0c0819eb3 Mon Sep 17 00:00:00 2001 From: Wayne Liang Date: Sun, 21 Apr 2024 12:50:02 +0800 Subject: [PATCH] fix[TextArea|Input|Mentions]: Fixed the issue where component values were reset to the previous state when components were re-patch under isComposing state --- components/input/TextArea.tsx | 2 +- components/vc-input/Input.tsx | 4 ++-- components/vc-mentions/src/Mentions.tsx | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/input/TextArea.tsx b/components/input/TextArea.tsx index f39da97d26..5a238cc239 100644 --- a/components/input/TextArea.tsx +++ b/components/input/TextArea.tsx @@ -173,7 +173,7 @@ export default defineComponent({ const { composing } = e.target as any; let triggerValue = (e.target as any).value; compositing.value = !!((e as any).isComposing && composing); - if ((compositing.value && props.lazy) || stateValue.value === triggerValue) return; + if (stateValue.value === triggerValue) return; if (hasMaxLength.value) { // 1. 复制粘贴超过maxlength的情况 2.未超过maxlength的情况 diff --git a/components/vc-input/Input.tsx b/components/vc-input/Input.tsx index 9d7d29c5a5..a51c267cc5 100644 --- a/components/vc-input/Input.tsx +++ b/components/vc-input/Input.tsx @@ -91,9 +91,9 @@ export default defineComponent({ }); }; const handleChange = (e: ChangeEvent) => { - const { value, composing } = e.target as any; + const { value } = e.target as any; // https://github.com/vueComponent/ant-design-vue/issues/2203 - if (((e as any).isComposing && composing && props.lazy) || stateValue.value === value) return; + if (stateValue.value === value) return; const newVal = e.target.value; resolveOnChange(inputRef.value, e, triggerChange); setValue(newVal); diff --git a/components/vc-mentions/src/Mentions.tsx b/components/vc-mentions/src/Mentions.tsx index 77cf05a472..1caa2756d6 100644 --- a/components/vc-mentions/src/Mentions.tsx +++ b/components/vc-mentions/src/Mentions.tsx @@ -60,8 +60,7 @@ export default defineComponent({ emit('change', val); }; - const onChange: EventHandler = ({ target: { value, composing }, isComposing }) => { - if (isComposing || composing) return; + const onChange: EventHandler = ({ target: { value } }) => { triggerChange(value); };