From 87ac6b337372cb0be373183400b39d508e473fc6 Mon Sep 17 00:00:00 2001 From: web-padawan Date: Tue, 26 Dec 2023 12:03:31 +0200 Subject: [PATCH 1/2] refactor!: update menu-bar submenu to not extend context-menu --- .../menu-bar/src/vaadin-menu-bar-submenu.js | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/menu-bar/src/vaadin-menu-bar-submenu.js b/packages/menu-bar/src/vaadin-menu-bar-submenu.js index 51bb69fc46..907c7c1e32 100644 --- a/packages/menu-bar/src/vaadin-menu-bar-submenu.js +++ b/packages/menu-bar/src/vaadin-menu-bar-submenu.js @@ -6,18 +6,25 @@ import './vaadin-menu-bar-item.js'; import './vaadin-menu-bar-list-box.js'; import './vaadin-menu-bar-overlay.js'; -import { html } from '@polymer/polymer/lib/utils/html-tag.js'; +import { html, PolymerElement } from '@polymer/polymer/polymer-element.js'; +import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js'; import { defineCustomElement } from '@vaadin/component-base/src/define.js'; -import { ContextMenu } from '@vaadin/context-menu/src/vaadin-context-menu.js'; +import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js'; +import { ContextMenuMixin } from '@vaadin/context-menu/src/vaadin-context-menu-mixin.js'; +import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js'; /** * An element used internally by ``. Not intended to be used separately. * * @customElement - * @extends ContextMenu + * @extends HTMLElement + * @mixes ContextMenuMixin + * @mixes ControllerMixin + * @mixes OverlayClassMixin + * @mixes ThemePropertyMixin * @protected */ -class MenuBarSubmenu extends ContextMenu { +class MenuBarSubmenu extends ContextMenuMixin(OverlayClassMixin(ControllerMixin(ThemePropertyMixin(PolymerElement)))) { static get is() { return 'vaadin-menu-bar-submenu'; } @@ -53,6 +60,19 @@ class MenuBarSubmenu extends ContextMenu { return 'vaadin-menu-bar'; } + /** + * @param {DocumentFragment} dom + * @return {null} + * @protected + * @override + */ + _attachDom(dom) { + const root = this.attachShadow({ mode: 'open' }); + root.appendChild(dom); + root.appendChild(this._overlayElement); + return root; + } + /** * Overriding the observer to not add global "contextmenu" listener. */ From 948370efd4c76f4a17622c0276e8811d754db555 Mon Sep 17 00:00:00 2001 From: web-padawan Date: Wed, 27 Dec 2023 13:29:51 +0200 Subject: [PATCH 2/2] docs: fix incorrect return type JSDoc for _attachDom --- packages/menu-bar/src/vaadin-menu-bar-submenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/menu-bar/src/vaadin-menu-bar-submenu.js b/packages/menu-bar/src/vaadin-menu-bar-submenu.js index 907c7c1e32..629791fd76 100644 --- a/packages/menu-bar/src/vaadin-menu-bar-submenu.js +++ b/packages/menu-bar/src/vaadin-menu-bar-submenu.js @@ -62,7 +62,7 @@ class MenuBarSubmenu extends ContextMenuMixin(OverlayClassMixin(ControllerMixin( /** * @param {DocumentFragment} dom - * @return {null} + * @return {ShadowRoot} * @protected * @override */