From e83481fe4aa996b9fe16fd59fc6b9b550b939b16 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: Mon, 24 Jul 2023 17:23:12 +0300 Subject: [PATCH] Refactor #4190 - For ContextMenu --- components/lib/contextmenu/ContextMenu.d.ts | 8 +++++++ components/lib/contextmenu/ContextMenuSub.vue | 24 ++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/components/lib/contextmenu/ContextMenu.d.ts b/components/lib/contextmenu/ContextMenu.d.ts index 8cc93c40b..6e5639162 100755 --- a/components/lib/contextmenu/ContextMenu.d.ts +++ b/components/lib/contextmenu/ContextMenu.d.ts @@ -141,6 +141,14 @@ export interface ContextMenuState { * Defines current options in ContextMenu component. */ export interface ContextMenuContext { + /** + * Current menuitem + */ + item: any; + /** + * Index of the menuitem + */ + index: number; /** * Current active state of menuitem as a boolean. * @defaultValue false diff --git a/components/lib/contextmenu/ContextMenuSub.vue b/components/lib/contextmenu/ContextMenuSub.vue index 19ec44486..cfedcab02 100755 --- a/components/lib/contextmenu/ContextMenuSub.vue +++ b/components/lib/contextmenu/ContextMenuSub.vue @@ -15,27 +15,27 @@ :aria-level="level + 1" :aria-setsize="getAriaSetSize()" :aria-posinset="getAriaPosInset(index)" - v-bind="getPTOptions(processedItem, 'menuitem')" + v-bind="getPTOptions('menuitem', processedItem, index)" :data-p-highlight="isItemActive(processedItem)" :data-p-focused="isItemFocused(processedItem)" :data-p-disabled="isItemDisabled(processedItem)" > -
+
@@ -139,11 +139,13 @@ export default { getItemLabel(processedItem) { return this.getItemProp(processedItem, 'label'); }, - getPTOptions(processedItem, key) { + getPTOptions(key, processedItem, index) { return this.ptm(key, { context: { + item: processedItem, active: this.isItemActive(processedItem), - focused: this.isItemFocused(processedItem) + focused: this.isItemFocused(processedItem), + index } }); },