From 7d86b48f28c67dd6e0132e1bb5732ee01971c532 Mon Sep 17 00:00:00 2001 From: tugcekucukoglu Date: Wed, 22 Nov 2023 13:36:31 +0300 Subject: [PATCH] Fixed #4862 - MegaMenu / Menubar: menubutton templating --- components/lib/megamenu/MegaMenu.d.ts | 23 ++++++++++++++ components/lib/megamenu/MegaMenu.vue | 38 ++++++++++++----------- components/lib/menubar/Menubar.d.ts | 30 ++++++++++++++++-- components/lib/menubar/Menubar.vue | 44 ++++++++++++++------------- 4 files changed, 93 insertions(+), 42 deletions(-) diff --git a/components/lib/megamenu/MegaMenu.d.ts b/components/lib/megamenu/MegaMenu.d.ts index 710876f5f..d6b64949e 100755 --- a/components/lib/megamenu/MegaMenu.d.ts +++ b/components/lib/megamenu/MegaMenu.d.ts @@ -318,6 +318,29 @@ export interface MegaMenuSlots { */ hasSubmenu: boolean; }): VNode[]; + /** + * Custom menu button template on responsive mode. + * @param {Object} scope - menu button slot's params. + */ + menubutton(scope: { + /** + * Current id state as a string + */ + id: string; + /** + * Style class of component + */ + class: string; + /** + * + * Toggle event + */ + toggleCallback: () => void; + }): VNode[]; + /** + * Custom menu button icon template on responsive mode. + */ + menubuttonicon(): VNode[]; /** * Custom submenu icon template. * @param {Object} scope - submenuicon slot's params. diff --git a/components/lib/megamenu/MegaMenu.vue b/components/lib/megamenu/MegaMenu.vue index ac1854d2d..c0ba7250e 100755 --- a/components/lib/megamenu/MegaMenu.vue +++ b/components/lib/megamenu/MegaMenu.vue @@ -3,24 +3,26 @@
- - - - - + + + + + + + void; + }): VNode[]; /** * Custom popup icon template on responsive mode. + * @deprecated since v3.42.0. Use 'menubuttonicon' slot instead. */ popupicon(): VNode[]; + /** + * Custom menu button icon template on responsive mode. + */ + menubuttonicon(): VNode[]; /** * Custom submenu icon template. * @param {Object} scope - submenuicon slot's params. diff --git a/components/lib/menubar/Menubar.vue b/components/lib/menubar/Menubar.vue index 62420da7a..e90310af2 100755 --- a/components/lib/menubar/Menubar.vue +++ b/components/lib/menubar/Menubar.vue @@ -3,24 +3,26 @@
- - - - - + + + + + + + { - const isOutsideContainer = this.menubar && !this.menubar.contains(event.target); - const isOutsideMenuButton = this.mobileActive && this.$refs.menubutton ? this.$refs.menubutton !== event.target && !this.$refs.menubutton.contains(event.target) : true; + const isOutsideContainer = this.container && !this.container.contains(event.target); + const isOutsideTarget = !(this.target && (this.target === event.target || this.target.contains(event.target))); - if (isOutsideMenuButton && isOutsideContainer) { + if (isOutsideContainer && isOutsideTarget) { this.hide(); } };