@vaadin/menu-bar 24.9.1 → 24.9.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/menu-bar",
3
- "version": "24.9.1",
3
+ "version": "24.9.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,22 +37,22 @@
37
37
  "dependencies": {
38
38
  "@open-wc/dedupe-mixin": "^1.3.0",
39
39
  "@polymer/polymer": "^3.0.0",
40
- "@vaadin/a11y-base": "~24.9.1",
41
- "@vaadin/button": "~24.9.1",
42
- "@vaadin/component-base": "~24.9.1",
43
- "@vaadin/context-menu": "~24.9.1",
44
- "@vaadin/item": "~24.9.1",
45
- "@vaadin/list-box": "~24.9.1",
46
- "@vaadin/overlay": "~24.9.1",
47
- "@vaadin/vaadin-lumo-styles": "~24.9.1",
48
- "@vaadin/vaadin-material-styles": "~24.9.1",
49
- "@vaadin/vaadin-themable-mixin": "~24.9.1",
40
+ "@vaadin/a11y-base": "~24.9.3",
41
+ "@vaadin/button": "~24.9.3",
42
+ "@vaadin/component-base": "~24.9.3",
43
+ "@vaadin/context-menu": "~24.9.3",
44
+ "@vaadin/item": "~24.9.3",
45
+ "@vaadin/list-box": "~24.9.3",
46
+ "@vaadin/overlay": "~24.9.3",
47
+ "@vaadin/vaadin-lumo-styles": "~24.9.3",
48
+ "@vaadin/vaadin-material-styles": "~24.9.3",
49
+ "@vaadin/vaadin-themable-mixin": "~24.9.3",
50
50
  "lit": "^3.0.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@vaadin/chai-plugins": "~24.9.1",
54
- "@vaadin/icon": "~24.9.1",
55
- "@vaadin/test-runner-commands": "~24.9.1",
53
+ "@vaadin/chai-plugins": "~24.9.3",
54
+ "@vaadin/icon": "~24.9.3",
55
+ "@vaadin/test-runner-commands": "~24.9.3",
56
56
  "@vaadin/testing-helpers": "^1.1.0",
57
57
  "sinon": "^18.0.0"
58
58
  },
@@ -60,5 +60,5 @@
60
60
  "web-types.json",
61
61
  "web-types.lit.json"
62
62
  ],
63
- "gitHead": "b5b40f63cd1a8adef39be3adb02050082476ca7e"
63
+ "gitHead": "dbb4c450495cd72e3d8662119e96db60a89f86ea"
64
64
  }
@@ -8,7 +8,7 @@ import { Directive, directive } from 'lit/directive.js';
8
8
  import { ifDefined } from 'lit/directives/if-defined.js';
9
9
  import { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
10
10
  import { FocusMixin } from '@vaadin/a11y-base/src/focus-mixin.js';
11
- import { isElementFocused, isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
11
+ import { isElementFocused, isElementHidden, isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
12
12
  import { KeyboardDirectionMixin } from '@vaadin/a11y-base/src/keyboard-direction-mixin.js';
13
13
  import { microTask } from '@vaadin/component-base/src/async.js';
14
14
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
@@ -549,12 +549,6 @@ export const MenuBarMixin = (superClass) =>
549
549
 
550
550
  const items = buttons.filter((b) => !remaining.includes(b)).map((b) => b.item);
551
551
  this.__updateOverflow(items);
552
-
553
- // Ensure there is at least one button with tabindex set to 0
554
- // so that menu-bar is not skipped when navigating with Tab
555
- if (remaining.length && !remaining.some((btn) => btn.getAttribute('tabindex') === '0')) {
556
- this._setTabindex(remaining[remaining.length - 1], true);
557
- }
558
552
  }
559
553
  }
560
554
 
@@ -585,13 +579,23 @@ export const MenuBarMixin = (superClass) =>
585
579
  const isSingleButton = newOverflowCount === buttons.length || (newOverflowCount === 0 && buttons.length === 1);
586
580
  this.toggleAttribute('has-single-button', isSingleButton);
587
581
 
582
+ // Collect visible buttons to detect if tabindex should be updated
583
+ const visibleButtons = buttons.filter((btn) => btn.style.visibility !== 'hidden');
584
+
585
+ if (!visibleButtons.length) {
586
+ // If all buttons except overflow are hidden, set tabindex on it
587
+ this._overflow.setAttribute('tabindex', '0');
588
+ } else if (!visibleButtons.some((btn) => btn.getAttribute('tabindex') === '0')) {
589
+ // Ensure there is at least one button with tabindex set to 0
590
+ // so that menu-bar is not skipped when navigating with Tab
591
+ this._setTabindex(visibleButtons[visibleButtons.length - 1], true);
592
+ }
593
+
588
594
  // Apply first/last visible attributes to the visible buttons
589
- buttons
590
- .filter((btn) => btn.style.visibility !== 'hidden')
591
- .forEach((btn, index, visibleButtons) => {
592
- btn.toggleAttribute('first-visible', index === 0);
593
- btn.toggleAttribute('last-visible', !this._hasOverflow && index === visibleButtons.length - 1);
594
- });
595
+ visibleButtons.forEach((btn, index, visibleButtons) => {
596
+ btn.toggleAttribute('first-visible', index === 0);
597
+ btn.toggleAttribute('last-visible', !this._hasOverflow && index === visibleButtons.length - 1);
598
+ });
595
599
  }
596
600
 
597
601
  /** @private */
@@ -781,7 +785,7 @@ export const MenuBarMixin = (superClass) =>
781
785
  */
782
786
  _setFocused(focused) {
783
787
  if (focused) {
784
- const target = this.tabNavigation ? this.querySelector('[focused]') : this.querySelector('[tabindex="0"]');
788
+ const target = this.__getFocusTarget();
785
789
  if (target) {
786
790
  this._buttons.forEach((btn) => {
787
791
  this._setTabindex(btn, btn === target);
@@ -795,6 +799,24 @@ export const MenuBarMixin = (superClass) =>
795
799
  }
796
800
  }
797
801
 
802
+ /** @private */
803
+ __getFocusTarget() {
804
+ // First, check if focus is moving to a visible button
805
+ let target = this._buttons.find((btn) => isElementFocused(btn));
806
+
807
+ if (!target) {
808
+ const selector = this.tabNavigation ? '[focused]' : '[tabindex="0"]';
809
+ // Next, check if there is a button that could be focused but is hidden
810
+ target = this.querySelector(`vaadin-menu-bar-button${selector}`);
811
+
812
+ if (isElementHidden(target)) {
813
+ target = this._buttons[this._getFocusableIndex()];
814
+ }
815
+ }
816
+
817
+ return target;
818
+ }
819
+
798
820
  /**
799
821
  * @param {!KeyboardEvent} event
800
822
  * @private
@@ -877,11 +899,11 @@ export const MenuBarMixin = (superClass) =>
877
899
  // Hide tooltip on mouseover to disabled button
878
900
  this._hideTooltip();
879
901
  } else if (button !== this._expandedButton) {
880
- const isOpened = this._subMenu.opened;
881
- if (button.item.children && (this.openOnHover || isOpened)) {
902
+ // Switch sub-menu when moving cursor over another button
903
+ // with children, regardless of whether openOnHover is set.
904
+ // If the button has no children, keep the sub-menu opened.
905
+ if (button.item.children && (this.openOnHover || this._subMenu.opened)) {
882
906
  this.__openSubMenu(button, false);
883
- } else if (isOpened) {
884
- this._close();
885
907
  }
886
908
 
887
909
  if (button === this._overflow || (this.openOnHover && button.item.children)) {
package/web-types.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/menu-bar",
4
- "version": "24.9.1",
4
+ "version": "24.9.3",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
8
8
  "elements": [
9
9
  {
10
10
  "name": "vaadin-menu-bar",
11
- "description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/24.9.1/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```\ndocument.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n------------------|----------------\n`container` | The container wrapping menu bar buttons.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n--------------------|----------------------------------\n`disabled` | Set when the menu bar is disabled\n`has-single-button` | Set when there is only one button visible\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-menu-bar>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/24.9.1/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.9.1/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.9.1/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.9.1/#/elements/vaadin-overlay).\n\nThe `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes\non top of the built-in `<vaadin-item>` state attributes:\n\nAttribute | Description\n---------- |-------------\n`expanded` | Expanded parent item.\n\nNote: the `theme` attribute value set on `<vaadin-menu-bar>` is\npropagated to the internal components listed above.",
11
+ "description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/24.9.3/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```\ndocument.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n------------------|----------------\n`container` | The container wrapping menu bar buttons.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n--------------------|----------------------------------\n`disabled` | Set when the menu bar is disabled\n`has-single-button` | Set when there is only one button visible\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-menu-bar>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/24.9.3/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.9.3/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.9.3/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.9.3/#/elements/vaadin-overlay).\n\nThe `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes\non top of the built-in `<vaadin-item>` state attributes:\n\nAttribute | Description\n---------- |-------------\n`expanded` | Expanded parent item.\n\nNote: the `theme` attribute value set on `<vaadin-menu-bar>` is\npropagated to the internal components listed above.",
12
12
  "attributes": [
13
13
  {
14
14
  "name": "disabled",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/menu-bar",
4
- "version": "24.9.1",
4
+ "version": "24.9.3",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -16,7 +16,7 @@
16
16
  "elements": [
17
17
  {
18
18
  "name": "vaadin-menu-bar",
19
- "description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/24.9.1/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```\ndocument.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n------------------|----------------\n`container` | The container wrapping menu bar buttons.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n--------------------|----------------------------------\n`disabled` | Set when the menu bar is disabled\n`has-single-button` | Set when there is only one button visible\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-menu-bar>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/24.9.1/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.9.1/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.9.1/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.9.1/#/elements/vaadin-overlay).\n\nThe `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes\non top of the built-in `<vaadin-item>` state attributes:\n\nAttribute | Description\n---------- |-------------\n`expanded` | Expanded parent item.\n\nNote: the `theme` attribute value set on `<vaadin-menu-bar>` is\npropagated to the internal components listed above.",
19
+ "description": "`<vaadin-menu-bar>` is a Web Component providing a set of horizontally stacked buttons offering\nthe user quick access to a consistent set of commands. Each button can toggle a submenu with\nsupport for additional levels of nested menus.\n\nTo create the menu bar, first add the component to the page:\n\n```\n<vaadin-menu-bar></vaadin-menu-bar>\n```\n\nAnd then use [`items`](https://cdn.vaadin.com/vaadin-web-components/24.9.3/#/elements/vaadin-menu-bar#property-items) property to initialize the structure:\n\n```\ndocument.querySelector('vaadin-menu-bar').items = [{text: 'File'}, {text: 'Edit'}];\n```\n\n### Styling\n\nThe following shadow DOM parts are exposed for styling:\n\nPart name | Description\n------------------|----------------\n`container` | The container wrapping menu bar buttons.\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n--------------------|----------------------------------\n`disabled` | Set when the menu bar is disabled\n`has-single-button` | Set when there is only one button visible\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.\n\n### Internal components\n\nIn addition to `<vaadin-menu-bar>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-menu-bar-button>` - has the same API as [`<vaadin-button>`](https://cdn.vaadin.com/vaadin-web-components/24.9.3/#/elements/vaadin-button).\n- `<vaadin-menu-bar-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.9.3/#/elements/vaadin-item).\n- `<vaadin-menu-bar-list-box>` - has the same API as [`<vaadin-list-box>`](https://cdn.vaadin.com/vaadin-web-components/24.9.3/#/elements/vaadin-list-box).\n- `<vaadin-menu-bar-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.9.3/#/elements/vaadin-overlay).\n\nThe `<vaadin-menu-bar-item>` sub-menu elements have the following additional state attributes\non top of the built-in `<vaadin-item>` state attributes:\n\nAttribute | Description\n---------- |-------------\n`expanded` | Expanded parent item.\n\nNote: the `theme` attribute value set on `<vaadin-menu-bar>` is\npropagated to the internal components listed above.",
20
20
  "extension": true,
21
21
  "attributes": [
22
22
  {