@primer/behaviors 0.0.0-202317231443 → 0.0.0-202342222036

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,8 @@ function getAnchoredPosition(floatingElement, anchorElement, settings = {}) {
26
26
  }
27
27
  exports.getAnchoredPosition = getAnchoredPosition;
28
28
  function getPositionedParent(element) {
29
+ if (isOnTopLayer(element))
30
+ return document.body;
29
31
  let parentNode = element.parentNode;
30
32
  while (parentNode !== null) {
31
33
  if (parentNode instanceof HTMLElement && getComputedStyle(parentNode).position !== 'static') {
@@ -35,6 +37,21 @@ function getPositionedParent(element) {
35
37
  }
36
38
  return document.body;
37
39
  }
40
+ function isOnTopLayer(element) {
41
+ var _a;
42
+ if (element.tagName === 'DIALOG') {
43
+ return true;
44
+ }
45
+ try {
46
+ if (element.matches(':popover-open') && /native code/.test((_a = document.body.showPopover) === null || _a === void 0 ? void 0 : _a.toString())) {
47
+ return true;
48
+ }
49
+ }
50
+ catch (_b) {
51
+ return false;
52
+ }
53
+ return false;
54
+ }
38
55
  function getClippingRect(element) {
39
56
  let parentNode = element;
40
57
  while (parentNode !== null) {
@@ -22,6 +22,8 @@ export function getAnchoredPosition(floatingElement, anchorElement, settings = {
22
22
  return pureCalculateAnchoredPosition(clippingRect, relativeRect, floatingElement.getBoundingClientRect(), anchorElement instanceof Element ? anchorElement.getBoundingClientRect() : anchorElement, getDefaultSettings(settings));
23
23
  }
24
24
  function getPositionedParent(element) {
25
+ if (isOnTopLayer(element))
26
+ return document.body;
25
27
  let parentNode = element.parentNode;
26
28
  while (parentNode !== null) {
27
29
  if (parentNode instanceof HTMLElement && getComputedStyle(parentNode).position !== 'static') {
@@ -31,6 +33,21 @@ function getPositionedParent(element) {
31
33
  }
32
34
  return document.body;
33
35
  }
36
+ function isOnTopLayer(element) {
37
+ var _a;
38
+ if (element.tagName === 'DIALOG') {
39
+ return true;
40
+ }
41
+ try {
42
+ if (element.matches(':popover-open') && /native code/.test((_a = document.body.showPopover) === null || _a === void 0 ? void 0 : _a.toString())) {
43
+ return true;
44
+ }
45
+ }
46
+ catch (_b) {
47
+ return false;
48
+ }
49
+ return false;
50
+ }
34
51
  function getClippingRect(element) {
35
52
  let parentNode = element;
36
53
  while (parentNode !== null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/behaviors",
3
- "version": "0.0.0-202317231443",
3
+ "version": "0.0.0-202342222036",
4
4
  "description": "Shared behaviors for JavaScript components",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",