This commit is contained in:
yumoqing 2026-02-28 13:56:45 +08:00
parent 315b15ae53
commit cd71cb3c3c
2 changed files with 10 additions and 2 deletions

View File

@ -612,6 +612,12 @@ hr {
} }
.auto-textarea { .auto-textarea {
/* 1. 确保计算模型一致 */
box-sizing: border-box;
/* 2. 允许元素内部处理滚动事件,不传递给父层 */
touch-action: pan-y;
/* 3. 极其重要:有些 H5 框架会禁用默认滚动,这里强制开启 */
pointer-events: auto !important;
width: 100%; width: 100%;
min-height: 40px; /* 初始高度 */ min-height: 40px; /* 初始高度 */
max-height: 150px; /* 最大高度:超过此高度将滚动 */ max-height: 150px; /* 最大高度:超过此高度将滚动 */

View File

@ -922,9 +922,9 @@ bricks.UiText =class extends bricks.UiType {
opts.dynsize = opts.dynsize || true; opts.dynsize = opts.dynsize || true;
opts.cfontsize = opts.cfontsize || 1; opts.cfontsize = opts.cfontsize || 1;
if (opts.css){ if (opts.css){
opts.css += 'auto-textarea'; opts.css += ' inputbox auto-textarea';
} else { } else {
opts.css = 'auto-textarea'; opts.css = 'inputbox auto-textarea';
} }
super(opts); super(opts);
this.uitype='text'; this.uitype='text';
@ -942,6 +942,8 @@ bricks.UiText =class extends bricks.UiType {
const scrollHeight = el.scrollHeight; const scrollHeight = el.scrollHeight;
// 3. 获取 CSS 中定义的 max-height (150px) // 3. 获取 CSS 中定义的 max-height (150px)
const maxHeight = parseInt(window.getComputedStyle(el).maxHeight); const maxHeight = parseInt(window.getComputedStyle(el).maxHeight);
const paddingTop = parseInt(style.paddingTop);
const paddingBottom = parseInt(style.paddingBottom);
if (scrollHeight >= maxHeight) { if (scrollHeight >= maxHeight) {
// 4. 如果内容高度超过最大高度,固定为最大高度并显示滚动条 // 4. 如果内容高度超过最大高度,固定为最大高度并显示滚动条