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}