diff --git a/api-generator/components/panelmenu.js b/api-generator/components/panelmenu.js
index b0cd7267f..ccc23a40c 100644
--- a/api-generator/components/panelmenu.js
+++ b/api-generator/components/panelmenu.js
@@ -10,6 +10,12 @@ const PanelMenuProps = [
type: "array",
default: "null",
description: "A map of keys to represent the expansion state in controlled mode."
+ },
+ {
+ name: "exact",
+ type: "boolean",
+ default: "true",
+ description: "Whether to apply 'router-link-active-exact' class if route exactly matches the item path."
}
];
diff --git a/src/components/panelmenu/PanelMenu.d.ts b/src/components/panelmenu/PanelMenu.d.ts
index efdef5b2a..fb541939e 100755
--- a/src/components/panelmenu/PanelMenu.d.ts
+++ b/src/components/panelmenu/PanelMenu.d.ts
@@ -3,6 +3,7 @@ import { VNode } from 'vue';
interface PanelMenuProps {
model?: any[];
expandedKeys?: any;
+ exact?: boolean;
}
declare class PanelMenu {
diff --git a/src/components/panelmenu/PanelMenu.vue b/src/components/panelmenu/PanelMenu.vue
index a5e53ede4..9b920af7c 100755
--- a/src/components/panelmenu/PanelMenu.vue
+++ b/src/components/panelmenu/PanelMenu.vue
@@ -4,13 +4,13 @@
-
-
@@ -48,6 +48,10 @@ export default {
expandedKeys: {
type: null,
default: null
+ },
+ exact: {
+ type: Boolean,
+ default: true
}
},
data() {
@@ -107,6 +111,12 @@ export default {
getPanelIcon(item) {
return ['p-menuitem-icon', item.icon];
},
+ getHeaderLinkClass(item, routerProps) {
+ return ['p-panelmenu-header-link', {
+ 'router-link-active': routerProps && routerProps.isActive,
+ 'router-link-active-exact': this.exact && routerProps && routerProps.isExactActive
+ }];
+ },
isActive(item) {
return this.expandedKeys ? this.expandedKeys[item.key] : item === this.activeItem;
},
diff --git a/src/components/panelmenu/PanelMenuSub.vue b/src/components/panelmenu/PanelMenuSub.vue
index e52379e84..08a13d767 100755
--- a/src/components/panelmenu/PanelMenuSub.vue
+++ b/src/components/panelmenu/PanelMenuSub.vue
@@ -3,13 +3,13 @@
-
-
+
+
-
@@ -20,7 +20,7 @@
+ :expandedKeys="expandedKeys" @item-toggle="$emit('item-toggle', $event)" :exact="exact"/>
@@ -45,6 +45,10 @@ export default {
expandedKeys: {
type: null,
default: null
+ },
+ exact: {
+ type: Boolean,
+ default: true
}
},
data() {
@@ -84,8 +88,12 @@ export default {
getItemClass(item) {
return ['p-menuitem', item.className];
},
- getLinkClass(item) {
- return ['p-menuitem-link', {'p-disabled': this.disabled(item)}];
+ linkClass(item, routerProps) {
+ return ['p-menuitem-link', {
+ 'p-disabled': this.disabled(item),
+ 'router-link-active': routerProps && routerProps.isActive,
+ 'router-link-active-exact': this.exact && routerProps && routerProps.isExactActive
+ }];
},
isActive(item) {
return this.expandedKeys ? this.expandedKeys[item.key] : item === this.activeItem;
diff --git a/src/views/panelmenu/PanelMenuDoc.vue b/src/views/panelmenu/PanelMenuDoc.vue
index 35dee5e55..412bd3152 100755
--- a/src/views/panelmenu/PanelMenuDoc.vue
+++ b/src/views/panelmenu/PanelMenuDoc.vue
@@ -154,6 +154,18 @@ export default {
</template>
</PanelMenu>
+
+
+
router-link with route configuration can also be used within templating for further customization.
+
+<PanelMenu :model="items">
+ <template #item="{item}">
+ <router-link :to="item.to" custom v-slot="{href, route, navigate, isActive, isExactActive}">
+ <a :href="href" @click="navigate" :class="{'active-link': isActive, 'active-link-exact": isExactActive}>{{route.fullPath}}</a>
+ </router-link>
+ </template>
+</PanelMenu>
+
Programmatic Control
@@ -376,6 +388,12 @@ export default {
array |
null |
A map of keys to represent the expansion state in controlled mode. |
+
+
+ exact |
+ boolean |
+ true |
+ Whether to apply 'router-link-active-exact' class if route exactly matches the item path. |