-
Notifications
You must be signed in to change notification settings - Fork 497
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
[Textarea] 设置autosize+切换页面后会多出一个textarea #4472
Comments
👋 @origin-coding,感谢给 TDesign 提出了 issue。 |
这个额外的 if (!hiddenTextarea) {
hiddenTextarea = document.createElement('textarea');
document.body.appendChild(hiddenTextarea);
} 销毁语句如下: hiddenTextarea.parentNode && hiddenTextarea.parentNode.removeChild(hiddenTextarea);
hiddenTextarea = null; 而且在 const adjustTextareaHeight = () => {
if (props.autosize === true) {
textareaStyle.value = calcTextareaHeight(refTextareaElem.value); // autosize设置为true时调用只有一个参数
} else if (props.autosize && typeof props.autosize === 'object') {
const { minRows, maxRows } = props.autosize;
textareaStyle.value = calcTextareaHeight(refTextareaElem.value, minRows, maxRows); // autosize设置为对象时调用参数有3个
} else if (attrs.rows) {
textareaStyle.value = { height: 'auto', minHeight: 'auto' };
} else if (attrs.style && refTextareaElem.value?.style?.height) {
textareaStyle.value = { height: refTextareaElem.value.style.height };
}
}; 可以回过头,再次查看 function calcTextareaHeight(
targetElement: HTMLTextAreaElement, minRows: RowsType = 1, maxRows: RowsType = null,
) 调用参数只有一个时,minRows不为null,maxRows为null;调用参数有三个时,minRows和maxRows都不为null。 if (maxRows !== null) {
let maxHeight = singleRowHeight * maxRows;
if (boxSizing === 'border-box') {
maxHeight = maxHeight + paddingSize + borderSize;
}
height = Math.min(maxHeight, height);
} 不过我并不是特别确定是不是这里的问题,我对于页面样式这部分不太了解。 |
TDesign Vue Next的文档官网上面也可以复现这个bug,只不过textarea没有显示,元素实际存在,而且也有报错。 |
谢谢反馈和提供思路 我们具体再排查下 |
…ge (#4539) * fix(textarea ): calculate the height of textarea after leaving the page close #4472 * chore: fix --------- Co-authored-by: wū yāng <[email protected]>
tdesign-vue-next 版本
1.9.7
重现链接
https://github.com/origin-coding/Alacrity
重现步骤
复现步骤
textarea
元素。复现注意事项
autosize
属性需要设置为对象,不设置或者设置为true都不会触发。这一点在文本哈希里面有体现,页面右下角的Textarea在获取聚焦并后退之后不会触发上述问题。期望结果
页面切换后不再显示这个Textarea,或者设置为display: none之类的属性让它不再显示
实际结果
No response
框架版本
Vue(3.4.31)
浏览器版本
No response
系统版本
No response
Node版本
No response
补充说明
No response
The text was updated successfully, but these errors were encountered: