-
Notifications
You must be signed in to change notification settings - Fork 83
/
vaadin-menu-bar-button.js
55 lines (49 loc) · 1.48 KB
/
vaadin-menu-bar-button.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* @license
* Copyright (c) 2019 - 2024 Vaadin Ltd.
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
*/
import { Button } from '@vaadin/button/src/vaadin-button.js';
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
registerStyles(
'vaadin-menu-bar-button',
css`
:host {
flex-shrink: 0;
}
:host([slot='overflow']) {
margin-inline-end: 0;
}
[part='label'] ::slotted(vaadin-menu-bar-item) {
position: relative;
z-index: 1;
}
`,
{ moduleId: 'vaadin-menu-bar-button-styles' },
);
/**
* An element used internally by `<vaadin-menu-bar>`. Not intended to be used separately.
*
* @customElement
* @extends Button
* @private
*/
class MenuBarButton extends Button {
static get is() {
return 'vaadin-menu-bar-button';
}
/**
* Override method inherited from `ButtonMixin`. Sets a flag based on whether the key is an active key. Unlike a mouse click, Enter and Space should also focus the first item. This flag is used in menu bar to identify the action that triggered the click.
*
* @param {KeyboardEvent} event
* @protected
* @override
*/
_onKeyDown(event) {
this.__triggeredWithActiveKeys = this._activeKeys.includes(event.key);
super._onKeyDown(event);
this.__triggeredWithActiveKeys = null;
}
}
defineCustomElement(MenuBarButton);