Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/base/src/delegate/ResizeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ const observedElements = new Map<HTMLElement, Array<ResizeObserverCallback>>();
const getResizeObserver = () => {
if (!resizeObserver) {
resizeObserver = new window.ResizeObserver(entries => {
entries.forEach(entry => {
const callbacks = observedElements.get(entry.target as HTMLElement);
// Callbacks could be async and we need to handle returned promises to comply with the eslint "no-misused-promises" rule.
// Although Promise.all awaits all, we don't additonal task after calling the callbacks and should not make any difference.
callbacks && Promise.all(callbacks.map((callback: ResizeObserverCallback) => callback()));
window.requestAnimationFrame(() => {
entries.forEach(entry => {
const callbacks = observedElements.get(entry.target as HTMLElement);
// Callbacks could be async and we need to handle returned promises to comply with the eslint "no-misused-promises" rule.
// Although Promise.all awaits all, we don't await the additional task after calling the callbacks and should not make any difference.
callbacks && Promise.all(callbacks.map((callback: ResizeObserverCallback) => callback()));
});
});
});
}
Expand Down