From 86a34cde8732394871215dd2ddbc0be0c5774257 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Wed, 18 Jan 2023 23:02:42 +0000 Subject: [PATCH] Fixed #3553 - PanelMenu: Link items can't be opened with a keyboard (slot issue) --- components/panelmenu/PanelMenu.vue | 15 +++++++++------ components/panelmenu/PanelMenuList.vue | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/components/panelmenu/PanelMenu.vue b/components/panelmenu/PanelMenu.vue index 9db93737b..d6752da0f 100644 --- a/components/panelmenu/PanelMenu.vue +++ b/components/panelmenu/PanelMenu.vue @@ -70,10 +70,18 @@ export default { }, data() { return { + id: this.$attrs.id, activeItem: null }; }, - + watch: { + '$attrs.id': function (newVal) { + this.id = newVal || UniqueComponentId(); + } + }, + mounted() { + this.id = this.id || UniqueComponentId(); + }, methods: { getItemProp(item, name) { return item ? ObjectUtils.getItemValue(item[name]) : undefined; @@ -250,11 +258,6 @@ export default { return ['p-submenu-icon', this.isItemActive(item) ? 'pi pi-chevron-down' : 'pi pi-chevron-right']; } }, - computed: { - id() { - return this.$attrs.id || UniqueComponentId(); - } - }, components: { PanelMenuList: PanelMenuList } diff --git a/components/panelmenu/PanelMenuList.vue b/components/panelmenu/PanelMenuList.vue index f3828fe97..15203566b 100644 --- a/components/panelmenu/PanelMenuList.vue +++ b/components/panelmenu/PanelMenuList.vue @@ -200,7 +200,7 @@ export default { onEnterKey(event) { if (ObjectUtils.isNotEmpty(this.focusedItem)) { const element = DomHandler.findSingle(this.$el, `li[id="${`${this.focusedItemId}`}"]`); - const anchorElement = element && DomHandler.findSingle(element, '.p-menuitem-link'); + const anchorElement = element && (DomHandler.findSingle(element, '.p-menuitem-link') || DomHandler.findSingle(element, 'a,button')); anchorElement ? anchorElement.click() : element && element.click(); }