@@ -158,12 +158,27 @@ function PrettyTextArea(props: Readonly<{
158
158
const playerNames = usePlayerNames ( ) ;
159
159
160
160
const textareaRef = useRef < HTMLTextAreaElement > ( null ) ;
161
+ const prettyTextAreaRef = useRef < HTMLDivElement > ( null ) ;
162
+
163
+ useEffect ( ( ) => {
164
+ const handleMouseMove = ( e : MouseEvent ) => {
165
+ if ( prettyTextAreaRef . current ) {
166
+ if ( prettyTextAreaRef . current . contains ( e . target as Node ) ) {
167
+ setHover ( true ) ;
168
+ } else {
169
+ setHover ( false ) ;
170
+ }
171
+ }
172
+ }
173
+ document . addEventListener ( "mousemove" , handleMouseMove ) ;
174
+ return ( ) => document . removeEventListener ( "mousemove" , handleMouseMove ) ;
175
+ } , [ ] ) ;
161
176
162
177
// Function to adjust textarea height
163
178
const adjustHeight = ( ) => {
164
179
if ( textareaRef . current ) {
165
180
textareaRef . current . style . height = "auto" ; // Reset height
166
- textareaRef . current . style . height = `${ textareaRef . current . scrollHeight } px` ; // Adjust to fit content
181
+ textareaRef . current . style . height = `calc(.25rem + ${ textareaRef . current . scrollHeight } px) ` ; // Adjust to fit content
167
182
}
168
183
} ;
169
184
@@ -173,16 +188,19 @@ function PrettyTextArea(props: Readonly<{
173
188
} , [ props . field , writing , hover ] ) ;
174
189
175
190
return < div
191
+ ref = { prettyTextAreaRef }
176
192
className = "pretty-text-area"
177
- onMouseEnter = { ( ) => setHover ( true ) }
178
- onMouseLeave = { ( ) => setHover ( false ) }
179
193
onTouchEnd = { ( ) => setWriting ( true ) }
180
194
onFocus = { ( ) => setWriting ( true ) }
181
- onBlur = { ( ) => { setWriting ( false ) ; setHover ( false ) } }
195
+ onBlur = { ( ) => setWriting ( false ) }
182
196
>
183
197
{ ( ! writing && ! hover ) ?
184
- < div className = "textarea" >
185
- < StyledText noLinks = { true } > { sanitizePlayerMessage ( replaceMentions ( props . field , playerNames ) ) } </ StyledText >
198
+ < div
199
+ className = "textarea"
200
+ >
201
+ < StyledText noLinks = { true } >
202
+ { sanitizePlayerMessage ( replaceMentions ( props . field , playerNames ) ) }
203
+ </ StyledText >
186
204
</ div >
187
205
:
188
206
< textarea
0 commit comments