From 32b5d39f7b43e86efc0dc1f320bedfecbcabc50f Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 30 Nov 2022 21:36:57 +0800 Subject: [PATCH] fix(Field): set selection range only when focused (#11333) --- packages/vant/src/field/Field.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/vant/src/field/Field.tsx b/packages/vant/src/field/Field.tsx index dfc34c445..d2f617f70 100644 --- a/packages/vant/src/field/Field.tsx +++ b/packages/vant/src/field/Field.tsx @@ -305,7 +305,9 @@ export default defineComponent({ if (inputRef.value && inputRef.value.value !== value) { const { selectionStart, selectionEnd } = inputRef.value; inputRef.value.value = value; - inputRef.value.setSelectionRange(selectionStart, selectionEnd); + if (state.focused) { + inputRef.value.setSelectionRange(selectionStart, selectionEnd); + } } if (value !== props.modelValue) {