From d47e176974a38cddf5cb0177e07b5a82872c480d Mon Sep 17 00:00:00 2001 From: Ash Date: Thu, 13 Jun 2024 12:05:33 +0100 Subject: [PATCH] fix(sanity): ignore sticky overlay regions with a falsey DOM node (#6910) --- .../src/core/presence/overlay/StickyOverlay.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/sanity/src/core/presence/overlay/StickyOverlay.tsx b/packages/sanity/src/core/presence/overlay/StickyOverlay.tsx index c7b8eee8de5..df535c66757 100644 --- a/packages/sanity/src/core/presence/overlay/StickyOverlay.tsx +++ b/packages/sanity/src/core/presence/overlay/StickyOverlay.tsx @@ -137,11 +137,17 @@ function regionsWithComputedRects( regions: ReportedPresenceData[], parent: HTMLElement, ): ReportedRegionWithRect[] { - return regions.map(([id, region]) => ({ - ...region, - id, - rect: getRelativeRect(region.element, parent), - })) + return ( + regions + // Note: This filter shouldn't be necessary, but some developers have experienced regions + // being passed to the function with a `null` element. + .filter(([, region]) => Boolean(region.element)) + .map(([id, region]) => ({ + ...region, + id, + rect: getRelativeRect(region.element, parent), + })) + ) } type Props = {margins: Margins; children: ReactNode}