Skip to content

Commit c29b437

Browse files
georgimkvPetyaMarkovaBogdanova
authored andcommitted
fix(framework): avoid ResizeObserver loop limit exceeded error (#6934)
Fixes #6924
1 parent 0938b5b commit c29b437

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/base/src/delegate/ResizeHandler.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ const observedElements = new Map<HTMLElement, Array<ResizeObserverCallback>>();
88
const getResizeObserver = () => {
99
if (!resizeObserver) {
1010
resizeObserver = new window.ResizeObserver(entries => {
11-
entries.forEach(entry => {
12-
const callbacks = observedElements.get(entry.target as HTMLElement);
13-
// Callbacks could be async and we need to handle returned promises to comply with the eslint "no-misused-promises" rule.
14-
// Although Promise.all awaits all, we don't additonal task after calling the callbacks and should not make any difference.
15-
callbacks && Promise.all(callbacks.map((callback: ResizeObserverCallback) => callback()));
11+
window.requestAnimationFrame(() => {
12+
entries.forEach(entry => {
13+
const callbacks = observedElements.get(entry.target as HTMLElement);
14+
// Callbacks could be async and we need to handle returned promises to comply with the eslint "no-misused-promises" rule.
15+
// Although Promise.all awaits all, we don't await the additional task after calling the callbacks and should not make any difference.
16+
callbacks && Promise.all(callbacks.map((callback: ResizeObserverCallback) => callback()));
17+
});
1618
});
1719
});
1820
}

0 commit comments

Comments
 (0)