Skip to content

Commit

Permalink
Merge pull request #208 from EnixCoda/EnixCoda-patch-1
Browse files Browse the repository at this point in the history
Update `anchored-position.ts` to support handling elements outside of `document.body` in `getClippingRect`
  • Loading branch information
jonrohan committed Oct 12, 2023
2 parents e5c079e + 666c2d7 commit 63a0c78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/brave-experts-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/behaviors": patch
---

Update `anchored-position.ts` to support handling elements outside of `document.body` in `getClippingRect`
2 changes: 1 addition & 1 deletion src/anchored-position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function isOnTopLayer(element: Element) {
function getClippingRect(element: Element): BoxPosition {
let parentNode: typeof element.parentNode = element
while (parentNode !== null) {
if (parentNode === document.body) {
if (!(parentNode instanceof Element)) {
break
}
const parentNodeStyle = getComputedStyle(parentNode as Element)
Expand Down

0 comments on commit 63a0c78

Please sign in to comment.