Skip to content

Commit 49b4b48

Browse files
committed
- fix primefaces#6164 optimize menu bar
- move getAriaSetSize to computed - optimize getAriaPosInset
1 parent 3a007b0 commit 49b4b48

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

packages/primevue/src/menubar/MenubarSub.vue

+11-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
:aria-expanded="isItemGroup(processedItem) ? isItemActive(processedItem) : undefined"
1313
:aria-haspopup="isItemGroup(processedItem) && !getItemProp(processedItem, 'to') ? 'menu' : undefined"
1414
:aria-level="level + 1"
15-
:aria-setsize="getAriaSetSize()"
15+
:aria-setsize="getAriaSetSize"
1616
:aria-posinset="getAriaPosInset(index)"
1717
v-bind="getPTOptions(processedItem, index, 'item')"
1818
:data-p-active="isItemActive(processedItem)"
@@ -123,6 +123,7 @@ export default {
123123
}
124124
},
125125
list: null,
126+
126127
methods: {
127128
getItemId(processedItem) {
128129
return `${this.menuId}_${processedItem.key}`;
@@ -176,11 +177,8 @@ export default {
176177
onItemMouseMove(event, processedItem) {
177178
this.$emit('item-mousemove', { originalEvent: event, processedItem });
178179
},
179-
getAriaSetSize() {
180-
return this.items.filter((processedItem) => this.isItemVisible(processedItem) && !this.getItemProp(processedItem, 'separator')).length;
181-
},
182180
getAriaPosInset(index) {
183-
return index - this.items.slice(0, index).filter((processedItem) => this.isItemVisible(processedItem) && this.getItemProp(processedItem, 'separator')).length + 1;
181+
return index - this.ariaPosInsetCompute.slice(0, index).length + 1;
184182
},
185183
getMenuItemProps(processedItem, index) {
186184
return {
@@ -213,6 +211,14 @@ export default {
213211
};
214212
}
215213
},
214+
computed: {
215+
ariaPosInsetCompute() {
216+
return this.items.filter((processedItem) => this.isItemVisible(processedItem) && this.getItemProp(processedItem, 'separator'));
217+
},
218+
getAriaSetSize() {
219+
return this.items.filter((processedItem) => this.isItemVisible(processedItem) && !this.getItemProp(processedItem, 'separator')).length;
220+
}
221+
},
216222
components: {
217223
AngleRightIcon: AngleRightIcon,
218224
AngleDownIcon: AngleDownIcon

0 commit comments

Comments
 (0)