@primer/view-components 0.18.1 → 0.18.2-rc.0f7098eb

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.
@@ -320,7 +320,6 @@ _ActionMenuElement_handleDialogItemActivated = function _ActionMenuElement_handl
320
320
  }
321
321
  };
322
322
  // a modal <dialog> element will close all popovers
323
- setTimeout(() => __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_show).call(this), 0);
324
323
  dialog.addEventListener('close', handleDialogClose, { signal });
325
324
  dialog.addEventListener('cancel', handleDialogClose, { signal });
326
325
  };
@@ -11,6 +11,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
11
11
  };
12
12
  var _DialogHelperElement_abortController;
13
13
  function dialogInvokerButtonHandler(event) {
14
+ var _a;
14
15
  const target = event.target;
15
16
  const button = target === null || target === void 0 ? void 0 : target.closest('button');
16
17
  if (!button || button.hasAttribute('disabled') || button.getAttribute('aria-disabled') === 'true')
@@ -25,6 +26,40 @@ function dialogInvokerButtonHandler(event) {
25
26
  // If the behaviour is allowed through the dialog will be shown but then
26
27
  // quickly hidden- as if it were never shown. This prevents that.
27
28
  event.preventDefault();
29
+ // In some older browsers, such as Chrome 122, when a top layer element (such as a dialog)
30
+ // opens from within a popover, the "hide all popovers" internal algorithm runs, hiding
31
+ // any popover that is currently open, regardless of whether or not another top layer element,
32
+ // such as a <dialog> is nested inside.
33
+ // See https://github.com/whatwg/html/issues/9998.
34
+ // This is fixed by https://github.com/whatwg/html/pull/10116, but while we still support browsers
35
+ // that present this bug, we must undo the work they did to hide ancestral popovers of the dialog:
36
+ let node = button;
37
+ let fixed = false;
38
+ while (node) {
39
+ node = (_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.closest('[popover]:not(:popover-open)');
40
+ if (node && node.popover === 'auto') {
41
+ node.classList.add('dialog-inside-popover-fix');
42
+ node.popover = 'manual';
43
+ node.showPopover();
44
+ fixed = true;
45
+ }
46
+ }
47
+ if (fixed) {
48
+ // We need to re-open the dialog as modal, and also ensure no close event listeners
49
+ // are trying to act on the close
50
+ dialog.addEventListener('close', e => e.stopImmediatePropagation(), { once: true });
51
+ dialog.close();
52
+ dialog.showModal();
53
+ dialog.addEventListener('close', () => {
54
+ for (const el of dialog.ownerDocument.querySelectorAll('.dialog-inside-popover-fix')) {
55
+ if (el.contains(dialog)) {
56
+ el.classList.remove('dialog-inside-popover-fix');
57
+ el.popover = 'auto';
58
+ el.showPopover();
59
+ }
60
+ }
61
+ }, { once: true });
62
+ }
28
63
  }
29
64
  }
30
65
  dialogId = button.getAttribute('data-close-dialog-id') || button.getAttribute('data-submit-dialog-id');
@@ -52,21 +87,6 @@ export class DialogHelperElement extends HTMLElement {
52
87
  for (const record of records) {
53
88
  if (record.target === this.dialog) {
54
89
  this.ownerDocument.body.classList.toggle('has-modal', this.dialog.hasAttribute('open'));
55
- // In some older browsers, such as Chrome 122, when a top layer element (such as a dialog)
56
- // opens from within a popover, the "hide all popovers" internal algorithm runs, hiding
57
- // any popover that is currently open, regardless of whether or not another top layer element,
58
- // such as a <dialog> is nested inside.
59
- // See https://github.com/whatwg/html/issues/9998.
60
- // This is fixed by https://github.com/whatwg/html/pull/10116, but while we still support browsers that present this bug,
61
- // we must undo the work they did to hide ancestral popovers of the dialog:
62
- if (this.dialog.hasAttribute('open')) {
63
- let node = this.dialog;
64
- while (node) {
65
- node = node.closest('[popover]:not(:popover-open)');
66
- if (node)
67
- node.showPopover();
68
- }
69
- }
70
90
  }
71
91
  }
72
92
  }).observe(this, { subtree: true, attributeFilter: ['open'] });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.18.1",
3
+ "version": "0.18.2-rc.0f7098eb",
4
4
  "description": "ViewComponents for the Primer Design System",
5
5
  "main": "app/assets/javascripts/primer_view_components.js",
6
6
  "module": "app/components/primer/primer.js",
@@ -3379,7 +3379,7 @@
3379
3379
  {
3380
3380
  "preview_path": "primer/alpha/dialog/dialog_inside_overlay",
3381
3381
  "name": "dialog_inside_overlay",
3382
- "snapshot": "false",
3382
+ "snapshot": "interactive",
3383
3383
  "skip_rules": {
3384
3384
  "wont_fix": [
3385
3385
  "region"
@@ -3143,7 +3143,7 @@
3143
3143
  {
3144
3144
  "preview_path": "primer/alpha/dialog/dialog_inside_overlay",
3145
3145
  "name": "dialog_inside_overlay",
3146
- "snapshot": "false",
3146
+ "snapshot": "interactive",
3147
3147
  "skip_rules": {
3148
3148
  "wont_fix": [
3149
3149
  "region"