From abc08d59db0de21b0d258a9ab942821f97a3dea2 Mon Sep 17 00:00:00 2001 From: Sergey Date: Mon, 31 Jul 2023 22:13:23 +0100 Subject: [PATCH] Add ignoring resize observer problems --- .../SidePanels/OutlinerPanel/OutlinerTree.tsx | 12 +++++++++--- tests/functional/cypress/support/e2e.ts | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/SidePanels/OutlinerPanel/OutlinerTree.tsx b/src/components/SidePanels/OutlinerPanel/OutlinerTree.tsx index 6e99a207c2..79fc6e8aa7 100644 --- a/src/components/SidePanels/OutlinerPanel/OutlinerTree.tsx +++ b/src/components/SidePanels/OutlinerPanel/OutlinerTree.tsx @@ -82,9 +82,15 @@ const OutlinerInnerTreeComponent: FC = observer(({ regio const blockRef = useRef(); const [height, setHeight] = useState(0); let resizeObserver:ResizeObserver|null = useMemo(() => { - return new ResizeObserver(debounce(() => { - setHeight(blockRef.current?.clientHeight || 1); - }, 16)); + let lastHeight = 0; + + return new ResizeObserver((entities) => { + if (!entities?.[0]?.contentRect || entities?.[0]?.contentRect?.height === lastHeight) { + return; + } + lastHeight = entities?.[0]?.contentRect?.height || 1; + setHeight(lastHeight); + }); }, []); useEffect(() => { diff --git a/tests/functional/cypress/support/e2e.ts b/tests/functional/cypress/support/e2e.ts index 45f834f010..f6fbdfb3e5 100644 --- a/tests/functional/cypress/support/e2e.ts +++ b/tests/functional/cypress/support/e2e.ts @@ -2,6 +2,9 @@ import { CURRENT_FLAGS } from '../../feature-flags'; import '@heartexlabs/ls-test/cypress/support/e2e'; beforeEach(() => { + cy.on('uncaught:exception', err => { + return !err.message.includes('ResizeObserver loop completed with undelivered notifications.'); + }); cy.on('window:before:load', (win) => { console.log('Setting feature flags', CURRENT_FLAGS); Object.assign(win, {