@vaadin/context-menu 23.1.0-alpha3 → 23.1.0-beta2

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.
package/lit.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './src/lit/renderer-directives.js';
package/lit.js ADDED
@@ -0,0 +1 @@
1
+ export * from './src/lit/renderer-directives.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/context-menu",
3
- "version": "23.1.0-alpha3",
3
+ "version": "23.1.0-beta2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -22,6 +22,8 @@
22
22
  "files": [
23
23
  "src",
24
24
  "theme",
25
+ "lit.js",
26
+ "lit.d.ts",
25
27
  "vaadin-*.d.ts",
26
28
  "vaadin-*.js"
27
29
  ],
@@ -35,19 +37,20 @@
35
37
  "dependencies": {
36
38
  "@open-wc/dedupe-mixin": "^1.3.0",
37
39
  "@polymer/polymer": "^3.0.0",
38
- "@vaadin/component-base": "23.1.0-alpha3",
39
- "@vaadin/item": "23.1.0-alpha3",
40
- "@vaadin/list-box": "23.1.0-alpha3",
41
- "@vaadin/vaadin-lumo-styles": "23.1.0-alpha3",
42
- "@vaadin/vaadin-material-styles": "23.1.0-alpha3",
43
- "@vaadin/vaadin-overlay": "23.1.0-alpha3",
44
- "@vaadin/vaadin-themable-mixin": "23.1.0-alpha3"
40
+ "@vaadin/component-base": "23.1.0-beta2",
41
+ "@vaadin/item": "23.1.0-beta2",
42
+ "@vaadin/list-box": "23.1.0-beta2",
43
+ "@vaadin/lit-renderer": "23.1.0-beta2",
44
+ "@vaadin/vaadin-lumo-styles": "23.1.0-beta2",
45
+ "@vaadin/vaadin-material-styles": "23.1.0-beta2",
46
+ "@vaadin/vaadin-overlay": "23.1.0-beta2",
47
+ "@vaadin/vaadin-themable-mixin": "23.1.0-beta2"
45
48
  },
46
49
  "devDependencies": {
47
50
  "@esm-bundle/chai": "^4.3.4",
48
- "@vaadin/polymer-legacy-adapter": "23.1.0-alpha3",
51
+ "@vaadin/polymer-legacy-adapter": "23.1.0-beta2",
49
52
  "@vaadin/testing-helpers": "^0.3.2",
50
53
  "sinon": "^13.0.2"
51
54
  },
52
- "gitHead": "8c9e64e8dfa158dd52a9bf6da351ff038c88ca85"
55
+ "gitHead": "f11f9245a0b5e6bf912725a501c27c24b74e7c8d"
53
56
  }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { TemplateResult } from 'lit';
7
+ import { DirectiveResult } from 'lit/directive.js';
8
+ import { LitRendererDirective } from '@vaadin/lit-renderer';
9
+ import { ContextMenu, ContextMenuRendererContext } from '../vaadin-context-menu.js';
10
+
11
+ export type ContextMenuLitRenderer = (context: ContextMenuRendererContext, menu: ContextMenu) => TemplateResult;
12
+
13
+ export class ContextMenuRendererDirective extends LitRendererDirective<ContextMenu, ContextMenuLitRenderer> {
14
+ /**
15
+ * Adds the renderer callback to the context-menu.
16
+ */
17
+ addRenderer(): void;
18
+
19
+ /**
20
+ * Runs the renderer callback on the context-menu.
21
+ */
22
+ runRenderer(): void;
23
+
24
+ /**
25
+ * Removes the renderer callback from the context-menu.
26
+ */
27
+ removeRenderer(): void;
28
+ }
29
+
30
+ /**
31
+ * A Lit directive for populating the content of the context-menu.
32
+ *
33
+ * The directive accepts a renderer callback returning a Lit template and assigns it to the context-menu
34
+ * via the `renderer` property. The renderer is called once to populate the content when assigned
35
+ * and whenever a single dependency or an array of dependencies changes.
36
+ * It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
37
+ *
38
+ * Dependencies can be a single value or an array of values.
39
+ * Values are checked against previous values with strict equality (`===`),
40
+ * so the check won't detect nested property changes inside objects or arrays.
41
+ * When dependencies are provided as an array, each item is checked against the previous value
42
+ * at the same index with strict equality. Nested arrays are also checked only by strict
43
+ * equality.
44
+ *
45
+ * Example of usage:
46
+ * ```js
47
+ * `<vaadin-context-menu
48
+ * ${contextMenuRenderer((context, menu) => html`...`)}
49
+ * ></vaadin-context-menu>`
50
+ * ```
51
+ *
52
+ * @param renderer the renderer callback that returns a Lit template.
53
+ * @param dependencies a single dependency or an array of dependencies
54
+ * which trigger a re-render when changed.
55
+ */
56
+ export declare function contextMenuRenderer(
57
+ renderer: ContextMenuLitRenderer,
58
+ dependencies?: unknown,
59
+ ): DirectiveResult<typeof ContextMenuRendererDirective>;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2022 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { directive } from 'lit/directive.js';
7
+ import { LitRendererDirective } from '@vaadin/lit-renderer';
8
+
9
+ export class ContextMenuRendererDirective extends LitRendererDirective {
10
+ /**
11
+ * Adds the renderer callback to the context-menu.
12
+ */
13
+ addRenderer() {
14
+ this.element.renderer = (root, contextMenu, context) => {
15
+ this.renderRenderer(root, context, contextMenu);
16
+ };
17
+ }
18
+
19
+ /**
20
+ * Runs the renderer callback on the context-menu.
21
+ */
22
+ runRenderer() {
23
+ this.element.requestContentUpdate();
24
+ }
25
+
26
+ /**
27
+ * Removes the renderer callback from the context-menu.
28
+ */
29
+ removeRenderer() {
30
+ this.element.renderer = null;
31
+ }
32
+ }
33
+
34
+ /**
35
+ * A Lit directive for populating the content of the context-menu.
36
+ *
37
+ * The directive accepts a renderer callback returning a Lit template and assigns it to the context-menu
38
+ * via the `renderer` property. The renderer is called once to populate the content when assigned
39
+ * and whenever a single dependency or an array of dependencies changes.
40
+ * It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
41
+ *
42
+ * Dependencies can be a single value or an array of values.
43
+ * Values are checked against previous values with strict equality (`===`),
44
+ * so the check won't detect nested property changes inside objects or arrays.
45
+ * When dependencies are provided as an array, each item is checked against the previous value
46
+ * at the same index with strict equality. Nested arrays are also checked only by strict
47
+ * equality.
48
+ *
49
+ * Example of usage:
50
+ * ```js
51
+ * `<vaadin-context-menu
52
+ * ${contextMenuRenderer((context, menu) => html`...`)}
53
+ * ></vaadin-context-menu>`
54
+ * ```
55
+ *
56
+ * @param renderer the renderer callback that returns a Lit template.
57
+ * @param dependencies a single dependency or an array of dependencies
58
+ * which trigger a re-render when changed.
59
+ */
60
+ export const contextMenuRenderer = directive(ContextMenuRendererDirective);
@@ -28,7 +28,7 @@ registerStyles(
28
28
  background-color: #fff;
29
29
  }
30
30
  `,
31
- { moduleId: 'vaadin-context-menu-overlay-styles' }
31
+ { moduleId: 'vaadin-context-menu-overlay-styles' },
32
32
  );
33
33
 
34
34
  /**
@@ -49,8 +49,8 @@ class ContextMenuOverlay extends PositionMixin(OverlayElement) {
49
49
  */
50
50
  parentOverlay: {
51
51
  type: Object,
52
- readOnly: true
53
- }
52
+ readOnly: true,
53
+ },
54
54
  };
55
55
  }
56
56
 
@@ -102,7 +102,7 @@ class ContextMenuOverlay extends PositionMixin(OverlayElement) {
102
102
  return {
103
103
  xMax: overlayRect.right - contentRect.width,
104
104
  xMin: overlayRect.left + contentRect.width,
105
- yMax
105
+ yMax,
106
106
  };
107
107
  }
108
108
 
@@ -118,17 +118,17 @@ class ContextMenuOverlay extends PositionMixin(OverlayElement) {
118
118
  // Horizontal adjustment
119
119
  const isLeftAligned = !!this.style.left;
120
120
  if (isLeftAligned) {
121
- this.style.left = parseFloat(this.style.left) + parseFloat(style.paddingLeft) + 'px';
121
+ this.style.left = `${parseFloat(this.style.left) + parseFloat(style.paddingLeft)}px`;
122
122
  } else {
123
- this.style.right = parseFloat(this.style.right) + parseFloat(style.paddingRight) + 'px';
123
+ this.style.right = `${parseFloat(this.style.right) + parseFloat(style.paddingRight)}px`;
124
124
  }
125
125
 
126
126
  // Vertical adjustment
127
127
  const isBottomAligned = !!this.style.bottom;
128
128
  if (isBottomAligned) {
129
- this.style.bottom = parseFloat(this.style.bottom) - parseFloat(style.paddingBottom) + 'px';
129
+ this.style.bottom = `${parseFloat(this.style.bottom) - parseFloat(style.paddingBottom)}px`;
130
130
  } else {
131
- this.style.top = parseFloat(this.style.top) - parseFloat(style.paddingTop) + 'px';
131
+ this.style.top = `${parseFloat(this.style.top) - parseFloat(style.paddingTop)}px`;
132
132
  }
133
133
  }
134
134
  }
@@ -17,7 +17,7 @@ export interface ContextMenuRendererContext {
17
17
  export type ContextMenuRenderer = (
18
18
  root: HTMLElement,
19
19
  contextMenu?: ContextMenu,
20
- context?: ContextMenuRendererContext
20
+ context?: ContextMenuRendererContext,
21
21
  ) => void;
22
22
 
23
23
  /**
@@ -289,13 +289,13 @@ declare class ContextMenu extends ElementMixin(ThemePropertyMixin(ItemsMixin(HTM
289
289
  addEventListener<K extends keyof ContextMenuEventMap>(
290
290
  type: K,
291
291
  listener: (this: ContextMenu, ev: ContextMenuEventMap[K]) => void,
292
- options?: boolean | AddEventListenerOptions
292
+ options?: boolean | AddEventListenerOptions,
293
293
  ): void;
294
294
 
295
295
  removeEventListener<K extends keyof ContextMenuEventMap>(
296
296
  type: K,
297
297
  listener: (this: ContextMenu, ev: ContextMenuEventMap[K]) => void,
298
- options?: boolean | EventListenerOptions
298
+ options?: boolean | EventListenerOptions,
299
299
  ): void;
300
300
  }
301
301
 
@@ -241,7 +241,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
241
241
  * of the context menu to listen for `openOn` events.
242
242
  */
243
243
  selector: {
244
- type: String
244
+ type: String,
245
245
  },
246
246
 
247
247
  /**
@@ -252,7 +252,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
252
252
  type: Boolean,
253
253
  value: false,
254
254
  notify: true,
255
- readOnly: true
255
+ readOnly: true,
256
256
  },
257
257
 
258
258
  /**
@@ -262,7 +262,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
262
262
  */
263
263
  openOn: {
264
264
  type: String,
265
- value: 'vaadin-contextmenu'
265
+ value: 'vaadin-contextmenu',
266
266
  },
267
267
 
268
268
  /**
@@ -274,9 +274,9 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
274
274
  */
275
275
  listenOn: {
276
276
  type: Object,
277
- value: function () {
277
+ value() {
278
278
  return this;
279
- }
279
+ },
280
280
  },
281
281
 
282
282
  /**
@@ -287,7 +287,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
287
287
  closeOn: {
288
288
  type: String,
289
289
  value: 'click',
290
- observer: '_closeOnChanged'
290
+ observer: '_closeOnChanged',
291
291
  },
292
292
 
293
293
  /**
@@ -302,7 +302,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
302
302
  * @type {ContextMenuRenderer | undefined}
303
303
  */
304
304
  renderer: {
305
- type: Function
305
+ type: Function,
306
306
  },
307
307
 
308
308
  /** @private */
@@ -316,25 +316,25 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
316
316
 
317
317
  /** @private */
318
318
  _phone: {
319
- type: Boolean
319
+ type: Boolean,
320
320
  },
321
321
 
322
322
  /** @private */
323
323
  _touch: {
324
324
  type: Boolean,
325
- value: isTouch
325
+ value: isTouch,
326
326
  },
327
327
 
328
328
  /** @private */
329
329
  _wide: {
330
- type: Boolean
330
+ type: Boolean,
331
331
  },
332
332
 
333
333
  /** @private */
334
334
  _wideMediaQuery: {
335
335
  type: String,
336
- value: '(min-device-width: 750px)'
337
- }
336
+ value: '(min-device-width: 750px)',
337
+ },
338
338
  };
339
339
  }
340
340
 
@@ -343,7 +343,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
343
343
  '_openedChanged(opened)',
344
344
  '_targetOrOpenOnChanged(listenOn, openOn)',
345
345
  '_rendererChanged(renderer, items)',
346
- '_touchOrWideChanged(_touch, _wide)'
346
+ '_touchOrWideChanged(_touch, _wide)',
347
347
  ];
348
348
  }
349
349
 
@@ -377,7 +377,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
377
377
  this.addController(
378
378
  new MediaQueryController(this._wideMediaQuery, (matches) => {
379
379
  this._wide = matches;
380
- })
380
+ }),
381
381
  );
382
382
 
383
383
  processTemplates(this);
@@ -430,12 +430,12 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
430
430
 
431
431
  /** @private */
432
432
  _setListenOnUserSelect(value) {
433
- // note: these styles don't seem to work in Firefox on iOS.
433
+ // Note: these styles don't seem to work in Firefox on iOS.
434
434
  this.listenOn.style.webkitTouchCallout = value;
435
435
  this.listenOn.style.webkitUserSelect = value; // Chrome, Safari, Firefox
436
436
  this.listenOn.style.userSelect = value;
437
437
 
438
- // note: because user-selection is disabled on the overlay
438
+ // Note: because user-selection is disabled on the overlay
439
439
  // before opening the menu the text could be already selected
440
440
  // so we need to clear that selection
441
441
  document.getSelection().removeAllRanges();
@@ -535,7 +535,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
535
535
  if (e && !this.opened) {
536
536
  this._context = {
537
537
  detail: e.detail,
538
- target: this._contextTarget(e)
538
+ target: this._contextTarget(e),
539
539
  };
540
540
 
541
541
  if (this._context.target) {
@@ -579,7 +579,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
579
579
  const overlay = this.$.overlay;
580
580
  const style = overlay.style;
581
581
 
582
- style[coord] = (parseInt(style[coord]) || 0) + diff + 'px';
582
+ style[coord] = `${(parseInt(style[coord]) || 0) + diff}px`;
583
583
  }
584
584
 
585
585
  /** @private */
@@ -618,25 +618,25 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
618
618
  if (!this.__isRTL) {
619
619
  if (x < wdthVport / 2 || x < xMax) {
620
620
  // Menu is displayed in the right side of the anchor
621
- style.left = x + 'px';
621
+ style.left = `${x}px`;
622
622
  } else {
623
623
  // Menu is displayed in the left side of the anchor
624
- style.right = Math.max(0, wdthVport - x) + 'px';
624
+ style.right = `${Math.max(0, wdthVport - x)}px`;
625
625
  this._setEndAligned(overlay);
626
626
  }
627
627
  } else if (x > wdthVport / 2 || x > xMin) {
628
628
  // Menu is displayed in the right side of the anchor
629
- style.right = Math.max(0, wdthVport - x) + 'px';
629
+ style.right = `${Math.max(0, wdthVport - x)}px`;
630
630
  } else {
631
631
  // Menu is displayed in the left side of the anchor
632
- style.left = x + 'px';
632
+ style.left = `${x}px`;
633
633
  this._setEndAligned(overlay);
634
634
  }
635
635
 
636
636
  if (y < hghtVport / 2 || y < yMax) {
637
- style.top = y + 'px';
637
+ style.top = `${y}px`;
638
638
  } else {
639
- style.bottom = Math.max(0, hghtVport - y) + 'px';
639
+ style.bottom = `${Math.max(0, hghtVport - y)}px`;
640
640
  overlay.setAttribute('bottom-aligned', '');
641
641
  }
642
642
  }
@@ -660,7 +660,7 @@ class ContextMenu extends ControllerMixin(ElementMixin(ThemePropertyMixin(ItemsM
660
660
  return this._getEventCoordinate(event.detail.sourceEvent, coord);
661
661
  }
662
662
  } else {
663
- const prop = 'client' + coord.toUpperCase();
663
+ const prop = `client${coord.toUpperCase()}`;
664
664
  const position = event.changedTouches ? event.changedTouches[0][prop] : event[prop];
665
665
 
666
666
  if (position === 0) {
@@ -11,34 +11,34 @@ register({
11
11
  deps: ['touchstart', 'touchmove', 'touchend', 'contextmenu'],
12
12
  flow: {
13
13
  start: ['touchstart', 'contextmenu'],
14
- end: ['contextmenu']
14
+ end: ['contextmenu'],
15
15
  },
16
16
 
17
17
  emits: ['vaadin-contextmenu'],
18
18
 
19
19
  info: {
20
- sourceEvent: null
20
+ sourceEvent: null,
21
21
  },
22
22
 
23
- reset: function () {
23
+ reset() {
24
24
  this.info.sourceEvent = null;
25
25
  this._cancelTimer();
26
26
  this.info.touchJob = null;
27
27
  this.info.touchStartCoords = null;
28
28
  },
29
29
 
30
- _cancelTimer: function () {
30
+ _cancelTimer() {
31
31
  if (this._timerId) {
32
32
  clearTimeout(this._timerId);
33
33
  delete this._fired;
34
34
  }
35
35
  },
36
36
 
37
- touchstart: function (e) {
37
+ touchstart(e) {
38
38
  this.info.sourceEvent = e;
39
39
  this.info.touchStartCoords = {
40
40
  x: e.changedTouches[0].clientX,
41
- y: e.changedTouches[0].clientY
41
+ y: e.changedTouches[0].clientY,
42
42
  };
43
43
 
44
44
  // After timeout event is already retargeted to the parent element in case there is one.
@@ -53,14 +53,14 @@ register({
53
53
  this.fire(t, ct.clientX, ct.clientY);
54
54
  }
55
55
 
56
- // needed to prevent any 'tap' gesture events from firing
56
+ // Needed to prevent any 'tap' gesture events from firing
57
57
  // which could potentially cancel/close the overlay.
58
58
  prevent('tap');
59
59
  }
60
- }, 500); // default setting for Android and iOS.
60
+ }, 500); // Default setting for Android and iOS.
61
61
  },
62
62
 
63
- touchmove: function (e) {
63
+ touchmove(e) {
64
64
  const moveThreshold = 15;
65
65
  const touchStartCoords = this.info.touchStartCoords;
66
66
  if (
@@ -71,14 +71,14 @@ register({
71
71
  }
72
72
  },
73
73
 
74
- touchend: function (e) {
74
+ touchend(e) {
75
75
  if (this._fired) {
76
76
  e.preventDefault();
77
77
  }
78
78
  this._cancelTimer();
79
79
  },
80
80
 
81
- contextmenu: function (e) {
81
+ contextmenu(e) {
82
82
  if (!e.shiftKey) {
83
83
  this.info.sourceEvent = e;
84
84
  this.fire(e.target, e.clientX, e.clientY);
@@ -86,16 +86,16 @@ register({
86
86
  }
87
87
  },
88
88
 
89
- fire: function (target, x, y) {
89
+ fire(target, x, y) {
90
90
  // NOTE(web-padawan): the code below is copied from `Polymer.Gestures._fire`,
91
91
  // which is not exported from `gestures.js` module for Polymer 3.
92
92
  const sourceEvent = this.info.sourceEvent;
93
93
  const ev = new Event('vaadin-contextmenu', { bubbles: true, cancelable: true, composed: true });
94
94
  ev.detail = { x, y, sourceEvent };
95
95
  target.dispatchEvent(ev);
96
- // forward `preventDefault` in a clean way
96
+ // Forward `preventDefault` in a clean way
97
97
  if (ev.defaultPrevented && sourceEvent && sourceEvent.preventDefault) {
98
98
  sourceEvent.preventDefault();
99
99
  }
100
- }
100
+ },
101
101
  });
@@ -95,7 +95,7 @@ export const ItemsMixin = (superClass) =>
95
95
  * ----------------|----------------|----------------
96
96
  * `:host` | expanded | Expanded parent item
97
97
  */
98
- items: Array
98
+ items: Array,
99
99
  };
100
100
  }
101
101
 
@@ -139,7 +139,7 @@ export const ItemsMixin = (superClass) =>
139
139
  __forwardFocus() {
140
140
  const overlay = this.$.overlay;
141
141
  const child = overlay.getFirstChild();
142
- // if parent item is not focused, do not focus submenu
142
+ // If parent item is not focused, do not focus submenu
143
143
  if (overlay.parentOverlay) {
144
144
  const parent = overlay.parentOverlay.querySelector('[expanded]');
145
145
  if (parent && parent.hasAttribute('focused') && child) {
@@ -178,9 +178,9 @@ export const ItemsMixin = (superClass) =>
178
178
  itemElement.dispatchEvent(
179
179
  new CustomEvent('opensubmenu', {
180
180
  detail: {
181
- children: itemElement._item.children
182
- }
183
- })
181
+ children: itemElement._item.children,
182
+ },
183
+ }),
184
184
  );
185
185
  }
186
186
 
@@ -263,10 +263,10 @@ export const ItemsMixin = (superClass) =>
263
263
  __toggleMenuComponentAttribute(component, attribute, on) {
264
264
  if (on) {
265
265
  component.setAttribute(attribute, '');
266
- component['__has-' + attribute] = true;
267
- } else if (component['__has-' + attribute]) {
266
+ component[`__has-${attribute}`] = true;
267
+ } else if (component[`__has-${attribute}`]) {
268
268
  component.removeAttribute(attribute);
269
- component['__has-' + attribute] = false;
269
+ component[`__has-${attribute}`] = false;
270
270
  }
271
271
  }
272
272
 
@@ -280,7 +280,9 @@ export const ItemsMixin = (superClass) =>
280
280
  `;
281
281
  flush();
282
282
  const listBox = root.querySelector('vaadin-context-menu-list-box');
283
- this._theme && listBox.setAttribute('theme', this._theme);
283
+ if (this._theme) {
284
+ listBox.setAttribute('theme', this._theme);
285
+ }
284
286
  listBox.classList.add('vaadin-menu-list-box');
285
287
  requestAnimationFrame(() => listBox.setAttribute('role', 'menu'));
286
288
 
@@ -334,7 +336,7 @@ export const ItemsMixin = (superClass) =>
334
336
  requestAnimationFrame(() => (this.__openListenerActive = true));
335
337
  const openSubMenu = (
336
338
  e,
337
- itemElement = e.composedPath().filter((e) => e.localName === 'vaadin-context-menu-item')[0]
339
+ itemElement = e.composedPath().filter((e) => e.localName === 'vaadin-context-menu-item')[0],
338
340
  ) => {
339
341
  // Delay enabling the mouseover listener to avoid it from triggering on parent menu open
340
342
  if (!this.__openListenerActive) {
@@ -373,7 +375,9 @@ export const ItemsMixin = (superClass) =>
373
375
  const shouldOpenSubMenu =
374
376
  (!isRTL && e.keyCode === 39) || (isRTL && e.keyCode === 37) || e.keyCode === 13 || e.keyCode === 32;
375
377
 
376
- shouldOpenSubMenu && openSubMenu(e);
378
+ if (shouldOpenSubMenu) {
379
+ openSubMenu(e);
380
+ }
377
381
  });
378
382
  } else {
379
383
  const listBox = root.querySelector('vaadin-context-menu-list-box');
@@ -31,7 +31,7 @@ const contextMenuOverlay = css`
31
31
  `;
32
32
 
33
33
  registerStyles('vaadin-context-menu-overlay', [menuOverlay, contextMenuOverlay], {
34
- moduleId: 'lumo-context-menu-overlay'
34
+ moduleId: 'lumo-context-menu-overlay',
35
35
  });
36
36
 
37
37
  registerStyles(
@@ -84,7 +84,7 @@ registerStyles(
84
84
  }
85
85
  }
86
86
  `,
87
- { moduleId: 'lumo-context-menu-list-box' }
87
+ { moduleId: 'lumo-context-menu-list-box' },
88
88
  );
89
89
 
90
90
  registerStyles(
@@ -124,5 +124,5 @@ registerStyles(
124
124
  padding-right: var(--lumo-space-m);
125
125
  }
126
126
  `,
127
- { moduleId: 'lumo-context-menu-item' }
127
+ { moduleId: 'lumo-context-menu-item' },
128
128
  );
@@ -12,7 +12,7 @@ const contextMenuOverlay = css`
12
12
  `;
13
13
 
14
14
  registerStyles('vaadin-context-menu-overlay', [menuOverlay, contextMenuOverlay], {
15
- moduleId: 'material-context-menu-overlay'
15
+ moduleId: 'material-context-menu-overlay',
16
16
  });
17
17
 
18
18
  registerStyles(
@@ -44,7 +44,7 @@ registerStyles(
44
44
  }
45
45
  }
46
46
  `,
47
- { moduleId: 'material-context-menu-list-box' }
47
+ { moduleId: 'material-context-menu-list-box' },
48
48
  );
49
49
 
50
50
  registerStyles(
@@ -79,5 +79,5 @@ registerStyles(
79
79
  background-color: var(--material-secondary-background-color);
80
80
  }
81
81
  `,
82
- { moduleId: 'material-context-menu-item' }
82
+ { moduleId: 'material-context-menu-item' },
83
83
  );