提交 47316adf 编写于 作者: Q qiang

fix: 修复 textarea 组件固定 box-sizing 导致部分情况显示异常的问题 question/121893

上级 841636ae
......@@ -46,6 +46,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
emits: ['confirm', 'linechange', ...fieldEmit],
setup(props, { emit }) {
const rootRef: Ref<HTMLElement | null> = ref(null)
const wrapperRef: Ref<HTMLElement | null> = ref(null)
const { fieldRef, state, scopedAttrsState, fixDisabledColor, trigger } =
useField(props, rootRef, emit)
const valueCompute = computed(() => state.value.split(LINEFEED))
......@@ -57,6 +58,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
(height) => {
const el = rootRef.value as HTMLElement
const lineEl = lineRef.value as HTMLElement
const wrapper = wrapperRef.value as HTMLElement
let lineHeight = parseFloat(getComputedStyle(el).lineHeight)
if (isNaN(lineHeight)) {
lineHeight = lineEl.offsetHeight
......@@ -68,7 +70,8 @@ export default /*#__PURE__*/ defineBuiltInComponent({
lineCount,
})
if (props.autoHeight) {
el.style.height = height + 'px'
el.style.height = 'auto'
wrapper.style.height = height + 'px'
}
}
)
......@@ -147,7 +150,7 @@ export default /*#__PURE__*/ defineBuiltInComponent({
)
return (
<uni-textarea ref={rootRef}>
<div class="uni-textarea-wrapper">
<div ref={wrapperRef} class="uni-textarea-wrapper">
<div
v-show={!state.value.length}
{...scopedAttrsState.attrs}
......
......@@ -7,7 +7,6 @@ uni-textarea {
line-height: normal;
white-space: pre-wrap;
word-break: break-all;
box-sizing: content-box !important;
}
uni-textarea[hidden] {
display: none;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册