@primer/view-components 0.26.0-rc.0433a691 → 0.26.0-rc.153f1afb
Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
15
15
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
16
16
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
17
17
|
};
|
18
|
-
var _ActionMenuElement_instances, _ActionMenuElement_abortController, _ActionMenuElement_originalLabel, _ActionMenuElement_inputName, _ActionMenuElement_invokerBeingClicked, _ActionMenuElement_softDisableItems, _ActionMenuElement_potentiallyDisallowActivation,
|
18
|
+
var _ActionMenuElement_instances, _ActionMenuElement_abortController, _ActionMenuElement_originalLabel, _ActionMenuElement_inputName, _ActionMenuElement_invokerBeingClicked, _ActionMenuElement_softDisableItems, _ActionMenuElement_potentiallyDisallowActivation, _ActionMenuElement_isAnchorActivationViaSpace, _ActionMenuElement_isActivation, _ActionMenuElement_handleInvokerActivated, _ActionMenuElement_handleDialogItemActivated, _ActionMenuElement_handleItemActivated, _ActionMenuElement_handleIncludeFragmentReplaced, _ActionMenuElement_handleFocusOut, _ActionMenuElement_show, _ActionMenuElement_hide, _ActionMenuElement_isOpen, _ActionMenuElement_setDynamicLabel, _ActionMenuElement_updateInput, _ActionMenuElement_firstItem_get;
|
19
19
|
import { controller, target } from '@github/catalyst';
|
20
20
|
import '@oddbird/popover-polyfill';
|
21
21
|
const validSelectors = ['[role="menuitem"]', '[role="menuitemcheckbox"]', '[role="menuitemradio"]'];
|
@@ -152,18 +152,13 @@ let ActionMenuElement = class ActionMenuElement extends HTMLElement {
|
|
152
152
|
return;
|
153
153
|
}
|
154
154
|
}
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
// is called. While calling preventDefault() appears to have no effect on link navigation, it skips
|
159
|
-
// form submission. The code below therefore only calls preventDefault() if the button has been
|
160
|
-
// activated by the space key, and manually submits the form if the button is a submit button.
|
161
|
-
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isKeyboardActivationViaSpace).call(this, event)) {
|
155
|
+
// Pressing the space key on a link will cause the page to scroll unless preventDefault() is called.
|
156
|
+
// We then click it manually to navigate.
|
157
|
+
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isAnchorActivationViaSpace).call(this, event)) {
|
162
158
|
event.preventDefault();
|
163
|
-
|
164
|
-
item.closest('form')?.submit();
|
165
|
-
}
|
159
|
+
item.click();
|
166
160
|
}
|
161
|
+
__classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_handleItemActivated).call(this, item);
|
167
162
|
return;
|
168
163
|
}
|
169
164
|
if (event.type === 'include-fragment-replaced') {
|
@@ -269,26 +264,18 @@ _ActionMenuElement_potentiallyDisallowActivation = function _ActionMenuElement_p
|
|
269
264
|
}
|
270
265
|
return false;
|
271
266
|
};
|
272
|
-
|
273
|
-
return
|
274
|
-
|
275
|
-
_ActionMenuElement_isKeyboardActivationViaEnter = function _ActionMenuElement_isKeyboardActivationViaEnter(event) {
|
276
|
-
return (event instanceof KeyboardEvent &&
|
277
|
-
event.type === 'keydown' &&
|
278
|
-
!(event.ctrlKey || event.altKey || event.metaKey || event.shiftKey) &&
|
279
|
-
event.key === 'Enter');
|
280
|
-
};
|
281
|
-
_ActionMenuElement_isKeyboardActivationViaSpace = function _ActionMenuElement_isKeyboardActivationViaSpace(event) {
|
282
|
-
return (event instanceof KeyboardEvent &&
|
267
|
+
_ActionMenuElement_isAnchorActivationViaSpace = function _ActionMenuElement_isAnchorActivationViaSpace(event) {
|
268
|
+
return (event.target instanceof HTMLAnchorElement &&
|
269
|
+
event instanceof KeyboardEvent &&
|
283
270
|
event.type === 'keydown' &&
|
284
271
|
!(event.ctrlKey || event.altKey || event.metaKey || event.shiftKey) &&
|
285
272
|
event.key === ' ');
|
286
273
|
};
|
287
|
-
_ActionMenuElement_isMouseActivation = function _ActionMenuElement_isMouseActivation(event) {
|
288
|
-
return event instanceof MouseEvent && event.type === 'click';
|
289
|
-
};
|
290
274
|
_ActionMenuElement_isActivation = function _ActionMenuElement_isActivation(event) {
|
291
|
-
|
275
|
+
// Some browsers fire MouseEvents (Firefox) and others fire PointerEvents (Chrome). Activating an item via
|
276
|
+
// enter or space counterintuitively fires one of these rather than a KeyboardEvent. Since PointerEvent
|
277
|
+
// inherits from MouseEvent, it is enough to check for MouseEvent here.
|
278
|
+
return (event instanceof MouseEvent && event.type === 'click') || __classPrivateFieldGet(this, _ActionMenuElement_instances, "m", _ActionMenuElement_isAnchorActivationViaSpace).call(this, event);
|
292
279
|
};
|
293
280
|
_ActionMenuElement_handleInvokerActivated = function _ActionMenuElement_handleInvokerActivated(event) {
|
294
281
|
event.preventDefault();
|
@@ -363,23 +350,6 @@ _ActionMenuElement_handleItemActivated = function _ActionMenuElement_handleItemA
|
|
363
350
|
detail: { item: item.parentElement, checked: this.isItemChecked(item.parentElement) },
|
364
351
|
}));
|
365
352
|
};
|
366
|
-
_ActionMenuElement_activateItem = function _ActionMenuElement_activateItem(event, item) {
|
367
|
-
const eventWillActivateByDefault = (event instanceof MouseEvent && event.type === 'click') ||
|
368
|
-
(event instanceof KeyboardEvent &&
|
369
|
-
event.type === 'keydown' &&
|
370
|
-
!(event.ctrlKey || event.altKey || event.metaKey || event.shiftKey) &&
|
371
|
-
event.key === 'Enter');
|
372
|
-
// if the event will result in activating the current item by default, i.e. is a
|
373
|
-
// mouse click or keyboard enter, bail out
|
374
|
-
if (eventWillActivateByDefault)
|
375
|
-
return;
|
376
|
-
// otherwise, event will not result in activation by default, so we stop it and
|
377
|
-
// simulate a click
|
378
|
-
/* eslint-disable-next-line no-restricted-syntax */
|
379
|
-
event.stopPropagation();
|
380
|
-
const elem = item;
|
381
|
-
elem.click();
|
382
|
-
};
|
383
353
|
_ActionMenuElement_handleIncludeFragmentReplaced = function _ActionMenuElement_handleIncludeFragmentReplaced() {
|
384
354
|
if (__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_firstItem_get))
|
385
355
|
__classPrivateFieldGet(this, _ActionMenuElement_instances, "a", _ActionMenuElement_firstItem_get).focus();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@primer/view-components",
|
3
|
-
"version": "0.26.0-rc.
|
3
|
+
"version": "0.26.0-rc.153f1afb",
|
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",
|