Skip to content

Commit

Permalink
- fix primefaces#6164 optimize menu bar
Browse files Browse the repository at this point in the history
- move getAriaSetSize to computed
- optimize getAriaPosInset
  • Loading branch information
avramz authored and LeaderbotX400 committed Aug 29, 2024
1 parent a44b11d commit c1bef6b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/primevue/src/menubar/MenubarSub.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -123,6 +123,7 @@ export default {
}
},
list: null,
methods: {
getItemId(processedItem) {
return `${this.menuId}_${processedItem.key}`;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c1bef6b

Please sign in to comment.