Skip to content

A platform for community discussion. Free, open, simple.

FIX: ensures rects is present before using it (#11930)

Joffrey JAFFEUX12a4fefef616
diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit.js b/app/assets/javascripts/select-kit/addon/components/select-kit.js
index 175a88e8901..4a352058732 100644
--- a/app/assets/javascripts/select-kit/addon/components/select-kit.js
+++ b/app/assets/javascripts/select-kit/addon/components/select-kit.js
@@ -883,16 +883,20 @@ export default Component.extend(
wrapper.style.height = `${height}px`;
if (placementStrategy === "fixed") {
const rects = this.element.getClientRects()[0];
- const bodyRects = body && body.getClientRects()[0];
- wrapper.style.position = "fixed";
- wrapper.style.left = `${rects.left}px`;
- if (topPlacement && bodyRects) {
- wrapper.style.top = `${rects.top - bodyRects.height}px`;
- } else {
- wrapper.style.top = `${rects.top}px`;
- }
- if (isDocumentRTL()) {
- wrapper.style.right = "unset";
+
+ if (rects) {
+ const bodyRects = body && body.getClientRects()[0];
+
+ wrapper.style.position = "fixed";
+ wrapper.style.left = `${rects.left}px`;
+ if (topPlacement && bodyRects) {
+ wrapper.style.top = `${rects.top - bodyRects.height}px`;
+ } else {
+ wrapper.style.top = `${rects.top}px`;
+ }
+ if (isDocumentRTL()) {
+ wrapper.style.right = "unset";
+ }
}
}
}