Skip to content

Commit

Permalink
fix(NcAppNavigation): fix native open link in a new tab
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii Shartsev <[email protected]>
  • Loading branch information
ShGKme committed Apr 4, 2023
1 parent a432ff5 commit 5c7756c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/components/NcAppNavigationItem/NcAppNavigationItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,23 @@ export default {
this.$emit('update:open', this.opened)
},
// forward click event
/**
* Handle link click
*
* @param {PointerEvent} event - Native click event
* @param {Function} [navigate] - VueRouter link's navigate if any
* @param {string} [routerLinkHref] - VueRouter link's href
*/
onClick(event, navigate, routerLinkHref) {
// Navigate is only defined if it is a router-link
navigate?.(event)
// Always forward native event
this.$emit('click', event)
// Prevent default link behaviour if it's a router-link
// Do not navigate with control keys - it is opening in a new tab
if (event.metaKey || event.altKey || event.ctrlKey || event.shiftKey) {
return
}
// Prevent default link behaviour if it's a router-link and navigate manually
if (routerLinkHref) {
navigate?.(event)
event.preventDefault()
}
},
Expand Down

0 comments on commit 5c7756c

Please sign in to comment.