@primer/behaviors 0.0.0-202317225018 → 0.0.0-202341016582

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,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) {
@@ -198,8 +198,7 @@ function focusZone(container, settings) {
198
198
  element.setAttribute('tabindex', '-1');
199
199
  }
200
200
  if (!currentFocusedElement) {
201
- const initialElement = typeof focusInStrategy === 'function' ? focusInStrategy(document.body) : getFirstFocusableElement();
202
- updateFocusedElement(initialElement);
201
+ updateFocusedElement(getFirstFocusableElement());
203
202
  }
204
203
  }
205
204
  function findInsertionIndex(elementsToInsert) {
@@ -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) {
@@ -195,8 +195,7 @@ export function focusZone(container, settings) {
195
195
  element.setAttribute('tabindex', '-1');
196
196
  }
197
197
  if (!currentFocusedElement) {
198
- const initialElement = typeof focusInStrategy === 'function' ? focusInStrategy(document.body) : getFirstFocusableElement();
199
- updateFocusedElement(initialElement);
198
+ updateFocusedElement(getFirstFocusableElement());
200
199
  }
201
200
  }
202
201
  function findInsertionIndex(elementsToInsert) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/behaviors",
3
- "version": "0.0.0-202317225018",
3
+ "version": "0.0.0-202341016582",
4
4
  "description": "Shared behaviors for JavaScript components",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",