Skip to content

Commit

Permalink
refactor: move items-outside-click listener to the constructor (#6545)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Sep 27, 2023
1 parent c42debf commit b32adb8
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions packages/context-menu/src/vaadin-contextmenu-items-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */
Expand Down

0 comments on commit b32adb8

Please sign in to comment.