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

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

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