Skip to content

Commit

Permalink
refactor: remove Polymer splice support for menu items (#6899)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Dec 1, 2023
1 parent b34f348 commit 2efbb6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions packages/menu-bar/src/vaadin-menu-bar-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
];
}

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -743,14 +747,6 @@ export const MenuBarMixin = (superClass) =>
}
}

/** @private */
_itemsChanged() {
const subMenu = this._subMenu;
if (subMenu && subMenu.opened) {
subMenu.close();
}
}

/**
* @param {!MouseEvent} e
* @protected
Expand Down
2 changes: 1 addition & 1 deletion packages/menu-bar/test/sub-menu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down

0 comments on commit 2efbb6a

Please sign in to comment.