From 49b4b48466ec97f515429a7d8dfd9fbb8230a682 Mon Sep 17 00:00:00 2001 From: uros Date: Fri, 2 Aug 2024 12:47:25 +0200 Subject: [PATCH] - fix #6164 optimize menu bar - move getAriaSetSize to computed - optimize getAriaPosInset --- packages/primevue/src/menubar/MenubarSub.vue | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/primevue/src/menubar/MenubarSub.vue b/packages/primevue/src/menubar/MenubarSub.vue index 1ae34fffd..155204142 100755 --- a/packages/primevue/src/menubar/MenubarSub.vue +++ b/packages/primevue/src/menubar/MenubarSub.vue @@ -12,7 +12,7 @@ :aria-expanded="isItemGroup(processedItem) ? isItemActive(processedItem) : undefined" :aria-haspopup="isItemGroup(processedItem) && !getItemProp(processedItem, 'to') ? 'menu' : undefined" :aria-level="level + 1" - :aria-setsize="getAriaSetSize()" + :aria-setsize="getAriaSetSize" :aria-posinset="getAriaPosInset(index)" v-bind="getPTOptions(processedItem, index, 'item')" :data-p-active="isItemActive(processedItem)" @@ -123,6 +123,7 @@ export default { } }, list: null, + methods: { getItemId(processedItem) { return `${this.menuId}_${processedItem.key}`; @@ -176,11 +177,8 @@ export default { onItemMouseMove(event, processedItem) { this.$emit('item-mousemove', { originalEvent: event, processedItem }); }, - getAriaSetSize() { - return this.items.filter((processedItem) => this.isItemVisible(processedItem) && !this.getItemProp(processedItem, 'separator')).length; - }, getAriaPosInset(index) { - return index - this.items.slice(0, index).filter((processedItem) => this.isItemVisible(processedItem) && this.getItemProp(processedItem, 'separator')).length + 1; + return index - this.ariaPosInsetCompute.slice(0, index).length + 1; }, getMenuItemProps(processedItem, index) { return { @@ -213,6 +211,14 @@ export default { }; } }, + computed: { + ariaPosInsetCompute() { + return this.items.filter((processedItem) => this.isItemVisible(processedItem) && this.getItemProp(processedItem, 'separator')); + }, + getAriaSetSize() { + return this.items.filter((processedItem) => this.isItemVisible(processedItem) && !this.getItemProp(processedItem, 'separator')).length; + } + }, components: { AngleRightIcon: AngleRightIcon, AngleDownIcon: AngleDownIcon