Skip to content

Commit 4a297c7

Browse files
authored
fix(textarea): autofocus until component is fully rendered (#5153)
* fix(textarea): defer focus until component is fully rendered * fix(textarea): autofocus after the element exists * chore: lint code
1 parent da6e7b6 commit 4a297c7

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

packages/components/textarea/textarea.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,11 @@ export default defineComponent({
185185
watch(refTextareaElem, (el) => {
186186
if (!el) return;
187187
adjustTextareaHeight();
188+
if (props.autofocus) {
189+
el.focus();
190+
}
188191
});
189192

190-
watch(
191-
() => props.autofocus,
192-
(val) => {
193-
if (val) {
194-
refTextareaElem.value.focus();
195-
}
196-
},
197-
);
198-
199193
watch(textareaStyle, (val) => {
200194
const { style } = attrs as { style: StyleValue };
201195
if (isObject(style)) {

0 commit comments

Comments
 (0)