From b32adb8cbb9c2a45d45744df3c3361cfc4b90919 Mon Sep 17 00:00:00 2001 From: Serhii Kulykov Date: Wed, 27 Sep 2023 10:25:57 +0300 Subject: [PATCH] refactor: move items-outside-click listener to the constructor (#6545) --- .../src/vaadin-contextmenu-items-mixin.js | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/context-menu/src/vaadin-contextmenu-items-mixin.js b/packages/context-menu/src/vaadin-contextmenu-items-mixin.js index 3a219e7b20..4ef7588281 100644 --- a/packages/context-menu/src/vaadin-contextmenu-items-mixin.js +++ b/packages/context-menu/src/vaadin-contextmenu-items-mixin.js @@ -71,18 +71,8 @@ export const ItemsMixin = (superClass) => }; } - /** - * Tag name prefix used by overlay, list-box and items. - * @protected - * @return {string} - */ - get _tagNamePrefix() { - return 'vaadin-context-menu'; - } - - /** @protected */ - ready() { - super.ready(); + constructor() { + super(); // Overlay's outside click listener doesn't work with modeless // overlays (submenus) so we need additional logic for it @@ -91,7 +81,18 @@ export const ItemsMixin = (superClass) => this.dispatchEvent(new CustomEvent('items-outside-click')); } }; - this.addEventListener('items-outside-click', () => this.items && this.close()); + this.addEventListener('items-outside-click', () => { + this.items && this.close(); + }); + } + + /** + * Tag name prefix used by overlay, list-box and items. + * @protected + * @return {string} + */ + get _tagNamePrefix() { + return 'vaadin-context-menu'; } /** @protected */