@primer/view-components 0.7.0 → 0.7.1-rc.2f1da828

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.
@@ -63,8 +63,9 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
63
63
  if (!id)
64
64
  return null;
65
65
  for (const el of this.querySelectorAll(`[aria-controls]`)) {
66
- if (el.getAttribute('aria-controls') === id)
66
+ if (el.getAttribute('aria-controls') === id) {
67
67
  return el;
68
+ }
68
69
  }
69
70
  return null;
70
71
  }
@@ -95,15 +96,18 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
95
96
  __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_setDynamicLabel).call(this);
96
97
  __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_updateInput).call(this);
97
98
  if (this.includeFragment) {
98
- this.includeFragment.addEventListener('include-fragment-replaced', this, { signal });
99
+ this.includeFragment.addEventListener('include-fragment-replaced', this, {
100
+ signal
101
+ });
99
102
  }
100
103
  }
101
104
  disconnectedCallback() {
102
105
  __classPrivateFieldGet(this, _ActionMenuElement_abortController, "f").abort();
103
106
  }
104
107
  handleEvent(event) {
105
- var _a, _b;
106
- if (event.target === this.invokerElement && __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isActivationKeydown).call(this, event)) {
108
+ var _a, _b, _c, _d, _e;
109
+ const activation = __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isActivationKeydown).call(this, event);
110
+ if (event.target === this.invokerElement && activation) {
107
111
  if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_firstItem_get)) {
108
112
  event.preventDefault();
109
113
  (_a = this.popoverElement) === null || _a === void 0 ? void 0 : _a.showPopover();
@@ -111,13 +115,40 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
111
115
  return;
112
116
  }
113
117
  }
114
- if (!((_b = this.popoverElement) === null || _b === void 0 ? void 0 : _b.matches(':popover-open')))
118
+ // Ignore events within dialogs within menus
119
+ if (((_b = event.target) === null || _b === void 0 ? void 0 : _b.closest('dialog')) || ((_c = event.target) === null || _c === void 0 ? void 0 : _c.closest('modal-dialog'))) {
120
+ return;
121
+ }
122
+ // If a dialog has been rendered within the menu, we do not want to hide
123
+ // the entire menu, as that will also hide the Dialog. Instead we want to
124
+ // show the Dialog while hiding just the visible part of the menu.
125
+ if ((activation || event.type === 'click') && ((_d = event.target) === null || _d === void 0 ? void 0 : _d.closest('[data-show-dialog-id]'))) {
126
+ const dialogInvoker = event.target.closest('[data-show-dialog-id]');
127
+ const dialog = this.ownerDocument.getElementById((dialogInvoker === null || dialogInvoker === void 0 ? void 0 : dialogInvoker.getAttribute('data-show-dialog-id')) || '');
128
+ if (dialogInvoker && dialog && this.contains(dialogInvoker) && this.contains(dialog)) {
129
+ this.querySelector('.ActionListWrap').style.display = 'none';
130
+ const dialog_controller = new AbortController();
131
+ const { signal } = dialog_controller;
132
+ const handleDialogClose = () => {
133
+ var _a, _b;
134
+ dialog_controller.abort();
135
+ this.querySelector('.ActionListWrap').style.display = '';
136
+ if ((_a = this.popoverElement) === null || _a === void 0 ? void 0 : _a.matches(':popover-open')) {
137
+ (_b = this.popoverElement) === null || _b === void 0 ? void 0 : _b.hidePopover();
138
+ }
139
+ };
140
+ dialog.addEventListener('close', handleDialogClose, { signal });
141
+ dialog.addEventListener('cancel', handleDialogClose, { signal });
142
+ return;
143
+ }
144
+ }
145
+ if (!((_e = this.popoverElement) === null || _e === void 0 ? void 0 : _e.matches(':popover-open')))
115
146
  return;
116
147
  if (event.type === 'include-fragment-replaced') {
117
148
  if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_firstItem_get))
118
149
  __classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_firstItem_get).focus();
119
150
  }
120
- else if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isActivationKeydown).call(this, event) || (event instanceof MouseEvent && event.type === 'click')) {
151
+ else if (activation || (event instanceof MouseEvent && event.type === 'click')) {
121
152
  // Hide popover after current event loop to prevent changes in focus from
122
153
  // altering the target of the event. Not doing this specifically affects
123
154
  // <a> tags. It causes the event to be sent to the currently focused element
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.7.0",
3
+ "version": "0.7.1-rc.2f1da828",
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",