fix: input textarea cursor pos error
parent
31c8339315
commit
66eb020ce1
|
@ -37,7 +37,6 @@ export function resolveOnChange(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const event: any = e;
|
const event: any = e;
|
||||||
const originalInputValue = target.value;
|
|
||||||
|
|
||||||
if (e.type === 'click') {
|
if (e.type === 'click') {
|
||||||
Object.defineProperty(event, 'target', {
|
Object.defineProperty(event, 'target', {
|
||||||
|
@ -48,13 +47,13 @@ export function resolveOnChange(
|
||||||
});
|
});
|
||||||
// click clear icon
|
// click clear icon
|
||||||
//event = Object.create(e);
|
//event = Object.create(e);
|
||||||
event.target = target;
|
const currentTarget = target.cloneNode(true);
|
||||||
event.currentTarget = target;
|
|
||||||
|
event.target = currentTarget;
|
||||||
|
event.currentTarget = currentTarget;
|
||||||
// change target ref value cause e.target.value should be '' when clear input
|
// change target ref value cause e.target.value should be '' when clear input
|
||||||
target.value = '';
|
(currentTarget as any).value = '';
|
||||||
onChange(event);
|
onChange(event);
|
||||||
// reset target ref value
|
|
||||||
target.value = originalInputValue;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Trigger by composition event, this means we need force change the input value
|
// Trigger by composition event, this means we need force change the input value
|
||||||
|
@ -227,7 +226,11 @@ export default defineComponent({
|
||||||
if (props.value === undefined) {
|
if (props.value === undefined) {
|
||||||
stateValue.value = value;
|
stateValue.value = value;
|
||||||
} else {
|
} else {
|
||||||
instance.update();
|
nextTick(() => {
|
||||||
|
if (inputRef.value.value !== stateValue.value) {
|
||||||
|
instance.update();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
callback && callback();
|
callback && callback();
|
||||||
|
|
|
@ -31,6 +31,7 @@ export default defineComponent({
|
||||||
const formItemContext = useInjectFormItemContext();
|
const formItemContext = useInjectFormItemContext();
|
||||||
const stateValue = ref(props.value === undefined ? props.defaultValue : props.value);
|
const stateValue = ref(props.value === undefined ? props.defaultValue : props.value);
|
||||||
const resizableTextArea = ref();
|
const resizableTextArea = ref();
|
||||||
|
const mergedValue = ref('');
|
||||||
const { prefixCls, size, direction } = useConfigInject('input', props);
|
const { prefixCls, size, direction } = useConfigInject('input', props);
|
||||||
const showCount = computed(() => {
|
const showCount = computed(() => {
|
||||||
return (props.showCount as any) === '' || props.showCount || false;
|
return (props.showCount as any) === '' || props.showCount || false;
|
||||||
|
@ -63,7 +64,11 @@ export default defineComponent({
|
||||||
if (props.value === undefined) {
|
if (props.value === undefined) {
|
||||||
stateValue.value = value;
|
stateValue.value = value;
|
||||||
} else {
|
} else {
|
||||||
resizableTextArea.value?.instance.update?.();
|
nextTick(() => {
|
||||||
|
if (resizableTextArea.value.textArea.value !== mergedValue.value) {
|
||||||
|
resizableTextArea.value?.instance.update?.();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
callback && callback();
|
callback && callback();
|
||||||
|
@ -152,7 +157,7 @@ export default defineComponent({
|
||||||
blur,
|
blur,
|
||||||
resizableTextArea,
|
resizableTextArea,
|
||||||
});
|
});
|
||||||
const mergedValue = ref('');
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
let val = fixControlledValue(stateValue.value) as string;
|
let val = fixControlledValue(stateValue.value) as string;
|
||||||
if (
|
if (
|
||||||
|
|
Loading…
Reference in New Issue