@primer/view-components 0.18.0 → 0.18.1-rc.096ff957

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.
@@ -18,7 +18,6 @@ function dialogInvokerButtonHandler(event) {
18
18
  // If the user is clicking a valid dialog trigger
19
19
  let dialogId = button === null || button === void 0 ? void 0 : button.getAttribute('data-show-dialog-id');
20
20
  if (dialogId) {
21
- event.stopPropagation();
22
21
  const dialog = document.getElementById(dialogId);
23
22
  if (dialog instanceof HTMLDialogElement) {
24
23
  dialog.showModal();
@@ -26,7 +25,6 @@ function dialogInvokerButtonHandler(event) {
26
25
  // If the behaviour is allowed through the dialog will be shown but then
27
26
  // quickly hidden- as if it were never shown. This prevents that.
28
27
  event.preventDefault();
29
- event.stopPropagation();
30
28
  }
31
29
  }
32
30
  dialogId = button.getAttribute('data-close-dialog-id') || button.getAttribute('data-submit-dialog-id');
@@ -54,6 +52,21 @@ export class DialogHelperElement extends HTMLElement {
54
52
  for (const record of records) {
55
53
  if (record.target === this.dialog) {
56
54
  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
+ }
57
70
  }
58
71
  }
59
72
  }).observe(this, { subtree: true, attributeFilter: ['open'] });
@@ -65,11 +78,8 @@ export class DialogHelperElement extends HTMLElement {
65
78
  handleEvent(event) {
66
79
  const target = event.target;
67
80
  const dialog = this.dialog;
68
- if (!(dialog === null || dialog === void 0 ? void 0 : dialog.open))
69
- return;
70
- // if the target is inside the dialog, but is not the dialog itself, leave
71
- // the dialog open
72
- if ((target === null || target === void 0 ? void 0 : target.closest('dialog')) === dialog && target !== dialog)
81
+ // The click target _must_ be the dialog element itself, and not elements underneath or inside.
82
+ if (target !== dialog || !(dialog === null || dialog === void 0 ? void 0 : dialog.open))
73
83
  return;
74
84
  const rect = dialog.getBoundingClientRect();
75
85
  const clickWasInsideDialog = rect.top <= event.clientY &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.18.0",
3
+ "version": "0.18.1-rc.096ff957",
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",
@@ -3375,6 +3375,19 @@
3375
3375
  "color-contrast"
3376
3376
  ]
3377
3377
  }
3378
+ },
3379
+ {
3380
+ "preview_path": "primer/alpha/dialog/dialog_inside_overlay",
3381
+ "name": "dialog_inside_overlay",
3382
+ "snapshot": "false",
3383
+ "skip_rules": {
3384
+ "wont_fix": [
3385
+ "region"
3386
+ ],
3387
+ "will_fix": [
3388
+ "color-contrast"
3389
+ ]
3390
+ }
3378
3391
  }
3379
3392
  ],
3380
3393
  "subcomponents": [
@@ -3139,6 +3139,19 @@
3139
3139
  "color-contrast"
3140
3140
  ]
3141
3141
  }
3142
+ },
3143
+ {
3144
+ "preview_path": "primer/alpha/dialog/dialog_inside_overlay",
3145
+ "name": "dialog_inside_overlay",
3146
+ "snapshot": "false",
3147
+ "skip_rules": {
3148
+ "wont_fix": [
3149
+ "region"
3150
+ ],
3151
+ "will_fix": [
3152
+ "color-contrast"
3153
+ ]
3154
+ }
3142
3155
  }
3143
3156
  ]
3144
3157
  },