Skip to content

Commit d47e176

Browse files
committed
fix(sanity): ignore sticky overlay regions with a falsey DOM node (#6910)
1 parent 8ed31fa commit d47e176

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

packages/sanity/src/core/presence/overlay/StickyOverlay.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,17 @@ function regionsWithComputedRects(
137137
regions: ReportedPresenceData[],
138138
parent: HTMLElement,
139139
): ReportedRegionWithRect<FieldPresenceData>[] {
140-
return regions.map(([id, region]) => ({
141-
...region,
142-
id,
143-
rect: getRelativeRect(region.element, parent),
144-
}))
140+
return (
141+
regions
142+
// Note: This filter shouldn't be necessary, but some developers have experienced regions
143+
// being passed to the function with a `null` element.
144+
.filter(([, region]) => Boolean(region.element))
145+
.map(([id, region]) => ({
146+
...region,
147+
id,
148+
rect: getRelativeRect(region.element, parent),
149+
}))
150+
)
145151
}
146152

147153
type Props = {margins: Margins; children: ReactNode}

0 commit comments

Comments
 (0)