Skip to content

Commit a18038f

Browse files
committed
fix(): add guard to ensure that elements are not null to prevent null reference in boundingRect call
1 parent 23ae259 commit a18038f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/components/src/utils/floating-components.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,22 @@ const getFloatingProps = (
123123
parent: HTMLElement,
124124
placement: string
125125
) => {
126+
if (!element || !parent) {
127+
return {
128+
top: 0,
129+
bottom: 0,
130+
right: 0,
131+
height: 0,
132+
width: 0,
133+
left: 0,
134+
childHeight: 0,
135+
childWidth: 0,
136+
correctedPlacement: placement,
137+
innerWidth: window.innerWidth,
138+
innerHeight: window.innerHeight
139+
};
140+
}
141+
126142
const childRect = element.getBoundingClientRect();
127143
const { top, height, bottom, right, left, width } =
128144
parent.getBoundingClientRect();

0 commit comments

Comments
 (0)