From e03ac66e4054d7bc567d9edcfaa1715be3553de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Tue, 18 Oct 2022 21:47:53 +0300 Subject: [PATCH] Refactor #3092 --- src/components/dock/DockSub.vue | 43 +++++++++++++++------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/src/components/dock/DockSub.vue b/src/components/dock/DockSub.vue index 4ade22b939..311b010118 100644 --- a/src/components/dock/DockSub.vue +++ b/src/components/dock/DockSub.vue @@ -16,16 +16,16 @@ @mouseleave="onListMouseLeave" > @@ -128,9 +128,12 @@ export default { navigate && navigate(event); }, onItemClick(event, processedItem) { + console.log(processedItem); + if (this.isSameMenuItem(event)) { const command = this.getItemProp(processedItem, 'command'); + console.log(processedItem); command && command({ originalEvent: event, item: processedItem.item }); } }, @@ -210,24 +213,16 @@ export default { onEndKey() { this.changeFocusedOptionIndex(DomHandler.find(this.$refs.list, 'li.p-dock-item:not(.p-disabled)').length - 1); }, - onSpaceKey(event) { - const menuitems = DomHandler.find(this.$refs.list, 'li.p-dock-item'); - const matchedOptionIndex = [...menuitems].findIndex((link) => link.id === this.focusedOptionId); + onSpaceKey() { + const element = DomHandler.findSingle(this.$refs.list, `li[id="${`${this.focusedOptionIndex}`}"]`); + const anchorElement = element && DomHandler.findSingle(element, '.p-dock-action'); - if (this.model[matchedOptionIndex].to) { - this.$router.push(this.model[matchedOptionIndex].to); - } else if (this.model[matchedOptionIndex].url) { - menuitems[matchedOptionIndex].children[0].children[0].click(); - } else { - this.onItemClick(event, this.model[matchedOptionIndex]); - } + anchorElement ? anchorElement.click() : element && element.click(); }, findNextOptionIndex(index) { const menuitems = DomHandler.find(this.$refs.list, 'li.p-dock-item:not(.p-disabled)'); const matchedOptionIndex = [...menuitems].findIndex((link) => link.id === index); - console.log(matchedOptionIndex); - return matchedOptionIndex > -1 ? matchedOptionIndex + 1 : 0; }, findPrevOptionIndex(index) {