fix(Field): set selection range only when focused (#11333)

This commit is contained in:
neverland 2022-11-30 21:36:57 +08:00 committed by GitHub
parent 4e9d830dbf
commit dde13fac3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -309,7 +309,9 @@ export default defineComponent({
if (inputRef.value && inputRef.value.value !== value) { if (inputRef.value && inputRef.value.value !== value) {
const { selectionStart, selectionEnd } = inputRef.value; const { selectionStart, selectionEnd } = inputRef.value;
inputRef.value.value = value; inputRef.value.value = value;
inputRef.value.setSelectionRange(selectionStart, selectionEnd); if (state.focused) {
inputRef.value.setSelectionRange(selectionStart, selectionEnd);
}
} }
if (value !== props.modelValue) { if (value !== props.modelValue) {