MCPcopy Create free account
hub / github.com/Seanium/ChatMap / adjustTextareaHeight

Function adjustTextareaHeight

components/chat-interface.tsx:85–101  ·  view source on GitHub ↗
(e: React.ChangeEvent<HTMLTextAreaElement>)

Source from the content-addressed store, hash-verified

83
84 // 调整文本域高度的函数
85 const adjustTextareaHeight = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
86 const target = e.target
87 // 更新查询
88 setQuery(target.value)
89
90 // 如果内容为空,直接重置高度
91 if (!target.value.trim()) {
92 target.style.height = "38px"
93 return
94 }
95
96 // 重置高度,让scrollHeight计算正确
97 target.style.height = "38px"
98 // 设置新高度,但限制最大高度为100px
99 const newHeight = Math.min(Math.max(target.scrollHeight, 38), 100)
100 target.style.height = `${newHeight}px`
101 }
102
103 // 重置文本框高度的函数
104 const resetTextareaHeight = () => {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected