From a7d250cb784eaf2b643b1b28d3338c74045536c3 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Tue, 21 Mar 2023 15:27:04 -0700 Subject: [PATCH] fix: flyouts resizing for blocks (#6914) * fix: flyouts resizing for blocks * chore: fix node build * chore: actually fix node --- core/events/utils.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/events/utils.ts b/core/events/utils.ts index 4c3ca57cd..e8505f38d 100644 --- a/core/events/utils.ts +++ b/core/events/utils.ts @@ -220,7 +220,17 @@ function fireInternal(event: Abstract) { } if (!FIRE_QUEUE.length) { // First event added; schedule a firing of the event queue. - setTimeout(fireNow, 0); + try { + // If we are in a browser context, we want to make sure that the event + // fires after blocks have been rerendered this frame. + requestAnimationFrame(() => { + setTimeout(fireNow, 0); + }); + } catch (e) { + // Otherwise we just want to delay so events can be coallesced. + // requestAnimationFrame will error triggering this. + setTimeout(fireNow, 0); + } } FIRE_QUEUE.push(event); }