From 2efbb6adcf5a4cb5c78cfd56fd3a88c005e8dac6 Mon Sep 17 00:00:00 2001 From: Serhii Kulykov Date: Fri, 1 Dec 2023 16:34:19 +0200 Subject: [PATCH] refactor: remove Polymer splice support for menu items (#6899) --- packages/menu-bar/src/vaadin-menu-bar-mixin.js | 16 ++++++---------- packages/menu-bar/test/sub-menu.test.js | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/menu-bar/src/vaadin-menu-bar-mixin.js b/packages/menu-bar/src/vaadin-menu-bar-mixin.js index f03a4fbddb..94f953b338 100644 --- a/packages/menu-bar/src/vaadin-menu-bar-mixin.js +++ b/packages/menu-bar/src/vaadin-menu-bar-mixin.js @@ -158,11 +158,10 @@ export const MenuBarMixin = (superClass) => static get observers() { return [ - '_itemsChanged(items, items.splices)', '_themeChanged(_theme, _overflow, _container)', '__hasOverflowChanged(_hasOverflow, _overflow)', '__i18nChanged(i18n, _overflow)', - '_menuItemsChanged(items, _overflow, _container, items.splices)', + '_menuItemsChanged(items, _overflow, _container)', ]; } @@ -338,6 +337,11 @@ export const MenuBarMixin = (superClass) => this._oldItems = items; this.__renderButtons(items); } + + const subMenu = this._subMenu; + if (subMenu && subMenu.opened) { + subMenu.close(); + } } /** @private */ @@ -743,14 +747,6 @@ export const MenuBarMixin = (superClass) => } } - /** @private */ - _itemsChanged() { - const subMenu = this._subMenu; - if (subMenu && subMenu.opened) { - subMenu.close(); - } - } - /** * @param {!MouseEvent} e * @protected diff --git a/packages/menu-bar/test/sub-menu.test.js b/packages/menu-bar/test/sub-menu.test.js index 74d64a0f47..555c5e7596 100644 --- a/packages/menu-bar/test/sub-menu.test.js +++ b/packages/menu-bar/test/sub-menu.test.js @@ -370,7 +370,7 @@ describe('sub-menu', () => { buttons[0].click(); await nextRender(subMenu); - menu.splice('items', 0, 1, { text: 'Menu Item 1' }); + menu.items = [...menu.items, { text: 'Menu Item 1' }]; await nextRender(subMenu); expect(subMenu.opened).to.be.false; });