Merge pull request #17422 from overleaf/jpa-avoid-resize-observer-loop

[web] avoid ResizeObserver loop when opening logs pane

GitOrigin-RevId: fb9c54e137785b34af01d031e182b66969711e41
This commit is contained in:
Jakob Ackermann 2024-04-16 09:36:45 +01:00 committed by Copybot
parent 91b67bc0bd
commit e100d85940

View file

@ -11,11 +11,12 @@ export default function PdfLogEntryRawContent({
collapsedSize = 0,
}) {
const [expanded, setExpanded] = useState(false)
const [needsExpander, setNeedsExpander] = useState(false)
const [needsExpander, setNeedsExpander] = useState(true)
const { elementRef } = useResizeObserver(
useCallback(
element => {
if (element.scrollHeight === 0) return // skip update when logs-pane is closed
setNeedsExpander(element.scrollHeight > collapsedSize)
},
[collapsedSize]