improvement(performance): modify the long-input resize behavior to maintain the same behavior but only update the state once the resize is complete

This commit is contained in:
Waleed Latif
2025-05-05 01:23:10 -07:00
parent fd53247f25
commit d2e91c2713
@@ -116,15 +116,21 @@ export function LongInput({
const deltaY = moveEvent.clientY - startY
const newHeight = Math.max(MIN_HEIGHT_PX, startHeight + deltaY)
setHeight(newHeight)
if (textareaRef.current && overlayRef.current) {
textareaRef.current.style.height = `${newHeight}px`
overlayRef.current.style.height = `${newHeight}px`
if (containerRef.current) {
containerRef.current.style.height = `${newHeight}px`
}
}
}
const handleMouseUp = () => {
if (textareaRef.current) {
const finalHeight = parseInt(textareaRef.current.style.height, 10) || height
setHeight(finalHeight)
}
isResizing.current = false
document.removeEventListener('mousemove', handleMouseMove)
document.removeEventListener('mouseup', handleMouseUp)