Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(textarea): value绑定值时,autosize时无法输入中文问题 #3057

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/textarea/textarea.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import Vue, { VueConstructor } from 'vue';
import isFunction from 'lodash/isFunction';
import merge from 'lodash/merge';
import { getUnicodeLength, limitUnicodeMaxLength } from '../_common/js/utils/helper';
import { getPropsApiByEvent, getCharacterLength } from '../utils/helper';
import calcTextareaHeight from './calcTextareaHeight';
import { renderTNodeJSX } from '../utils/render-tnode';
import { ClassName } from '../common';
import { getClassPrefixMixins } from '../config-provider/config-receiver';
import mixins from '../utils/mixins';
import setStyle from '../_common/js/utils/set-style';

import props from './props';
import type { TextareaValue } from './type';
Expand Down Expand Up @@ -119,6 +121,13 @@ export default mixins(Vue as VueConstructor<Textarea>, classPrefixMixins).extend
},
immediate: true,
},
textareaStyle: {
handler(val) {
const { style } = this.$attrs;
setStyle(this.$refs.refTextareaElem as HTMLTextAreaElement, merge(style, val));
},
immediate: true,
},
},

methods: {
Expand Down Expand Up @@ -265,7 +274,6 @@ export default mixins(Vue as VueConstructor<Textarea>, classPrefixMixins).extend
{...{ attrs: { ...this.$attrs, ...this.inputAttrs }, on: inputEvents }}
value={this.value}
class={classes}
style={this.textareaStyle}
ref="refTextareaElem"
></textarea>
{textTips || limitText ? (
Expand Down
Loading