From b89643cef12fffdee351e9287e1953a26eb6e5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Tue, 25 Jul 2023 12:11:12 +0300 Subject: [PATCH] Refactor #4190 - For MegaMenu --- components/lib/megamenu/MegaMenu.d.ts | 8 ++++++++ components/lib/megamenu/MegaMenuSub.vue | 24 +++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/components/lib/megamenu/MegaMenu.d.ts b/components/lib/megamenu/MegaMenu.d.ts index 248b41f06..05d9a8539 100755 --- a/components/lib/megamenu/MegaMenu.d.ts +++ b/components/lib/megamenu/MegaMenu.d.ts @@ -154,6 +154,14 @@ export interface MegaMenuState { * Defines current options in MegaMenu component. */ export interface MegaMenuContext { + /** + * Current menuitem + */ + item: any; + /** + * Current index of the menuitem. + */ + index: number; /** * Current active state of menuitem as a boolean. * @defaultValue false diff --git a/components/lib/megamenu/MegaMenuSub.vue b/components/lib/megamenu/MegaMenuSub.vue index d972626b1..00304d3bf 100644 --- a/components/lib/megamenu/MegaMenuSub.vue +++ b/components/lib/megamenu/MegaMenuSub.vue @@ -15,27 +15,27 @@ :aria-level="level + 1" :aria-setsize="getAriaSetSize()" :aria-posinset="getAriaPosInset(index)" - v-bind="getPTOptions(processedItem, 'menuitem')" + v-bind="getPTOptions(processedItem, index, 'menuitem')" :data-p-highlight="isItemActive(processedItem)" :data-p-focused="isItemFocused(processedItem)" :data-p-disabled="isItemDisabled(processedItem)" > -
+
@@ -150,9 +150,11 @@ export default { getItemLabel(processedItem) { return this.getItemProp(processedItem, 'label'); }, - getPTOptions(processedItem, key) { + getPTOptions(processedItem, index, key) { return this.ptm(key, { context: { + item: processedItem, + index, active: this.isItemActive(processedItem), focused: this.isItemFocused(processedItem) }