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

I don't have a clear reproduction ATM, but I imagine that in fast tests element can get destroyed before we get to use it.
This commit is contained in:
Joffrey JAFFEUX 2021-02-02 14:43:13 +01:00 committed by GitHub
parent fa33e4863d
commit 12a4fefef6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 10 deletions

View File

@ -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";
}
}
}
}