From db03876549de543e8f0f23d09da87717d90ab8c4 Mon Sep 17 00:00:00 2001 From: liukun <953831480@qq.com> Date: Tue, 29 Jul 2025 20:44:26 -0700 Subject: [PATCH] fix(input):fix textarea height in Multiple line placeholders (#3624) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update App.vue * fix:多行占位符导致文本域高度计算错误 --- examples/sites/src/App.vue | 1 + packages/renderless/src/input/index.ts | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/sites/src/App.vue b/examples/sites/src/App.vue index 38383728e..efc20b12d 100644 --- a/examples/sites/src/App.vue +++ b/examples/sites/src/App.vue @@ -136,6 +136,7 @@ const handleShowTinyRobot = () => { padding: 34px 0 0; } } + .right-panel:not(.collapsed) { :deep(.tr-container) { z-index: 9999; diff --git a/packages/renderless/src/input/index.ts b/packages/renderless/src/input/index.ts index 33a33c8a2..af9d5bc9f 100644 --- a/packages/renderless/src/input/index.ts +++ b/packages/renderless/src/input/index.ts @@ -124,7 +124,9 @@ export const calcTextareaHeight = const { paddingSize, borderSize, boxSizing, contextStyle } = api.calculateNodeStyling(targetElement) hiddenTextarea.setAttribute('style', `${contextStyle};${HIDDEN_STYLE}`) - hiddenTextarea.value = targetElement.value || targetElement.placeholder || '' + // 多行placeholder只计算单行高度防止撑高scrollHeight + const safePlaceholder = targetElement.placeholder ? targetElement.placeholder.trim().split('\n')[0] : '' + hiddenTextarea.value = targetElement.value || safePlaceholder || '' let height = hiddenTextarea.scrollHeight const textareaStyle: { @@ -161,11 +163,7 @@ export const calcTextareaHeight = minHeight = props.height } if (!state.isDisplayOnly) { - if (props.autosize) { - height = Math.max(minHeight, height) - } else { - height = Math.min(minHeight, height) - } + height = Math.max(minHeight, height) textareaStyle.minHeight = `${Math.floor(minHeight)}px` } else { textareaStyle.minHeight = `0px`