@primer/behaviors 1.3.3-rc.be41306 → 1.3.4-rc.8269a12

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @primer/behaviors
2
2
 
3
+ ## 1.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#195](https://github.com/primer/behaviors/pull/195) [`bddd6c5`](https://github.com/primer/behaviors/commit/bddd6c5be9af240d43a53cc062a0f07a65e695af) Thanks [@keithamus](https://github.com/keithamus)! - Special case anchored-position calls on top-layer elements
8
+
3
9
  ## 1.3.3
4
10
 
5
11
  ### Patch Changes
@@ -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,20 @@ function getPositionedParent(element) {
35
37
  }
36
38
  return document.body;
37
39
  }
40
+ function isOnTopLayer(element) {
41
+ if (element.tagName === 'DIALOG') {
42
+ return true;
43
+ }
44
+ try {
45
+ if (element.matches(':popover-open')) {
46
+ return true;
47
+ }
48
+ }
49
+ catch (_a) {
50
+ return false;
51
+ }
52
+ return false;
53
+ }
38
54
  function getClippingRect(element) {
39
55
  let parentNode = element;
40
56
  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,20 @@ function getPositionedParent(element) {
31
33
  }
32
34
  return document.body;
33
35
  }
36
+ function isOnTopLayer(element) {
37
+ if (element.tagName === 'DIALOG') {
38
+ return true;
39
+ }
40
+ try {
41
+ if (element.matches(':popover-open')) {
42
+ return true;
43
+ }
44
+ }
45
+ catch (_a) {
46
+ return false;
47
+ }
48
+ return false;
49
+ }
34
50
  function getClippingRect(element) {
35
51
  let parentNode = element;
36
52
  while (parentNode !== null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/behaviors",
3
- "version": "1.3.3-rc.be41306",
3
+ "version": "1.3.4-rc.8269a12",
4
4
  "description": "Shared behaviors for JavaScript components",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",