Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
Add ignoring resize observer problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Gondragos committed Jul 31, 2023
1 parent d0374df commit abc08d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/components/SidePanels/OutlinerPanel/OutlinerTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,15 @@ const OutlinerInnerTreeComponent: FC<OutlinerInnerTreeProps> = observer(({ regio
const blockRef = useRef<HTMLElement>();
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(() => {
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit abc08d5

Please sign in to comment.