Skip to content

Commit

Permalink
fix(NcUserBubble): add RouterLink support
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Aug 3, 2024
1 parent 74c5284 commit 4eb1820
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/components/NcUserBubble/NcUserBubble.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ export default {
<component :is="isLinkComponent"
class="user-bubble__content"
:style="styles.content"
:href="hasUrl ? url : null"
:class="{ 'user-bubble__content--primary': primary, 'user-bubble__content--clickable': isClickable }"
v-bind="attrs"
v-bind="{ ...linkAttrs, ...attrs }"
@click="onClick">
<!-- NcAvatar -->
<NcAvatar :url="isCustomAvatar && isAvatarUrl ? avatarImage : undefined"
Expand Down Expand Up @@ -130,7 +129,9 @@ export default {
import NcUserBubbleDiv from './NcUserBubbleDiv.vue'
import NcAvatar from '../NcAvatar/index.js'
import NcPopover from '../NcPopover/index.js'
import { getRoute } from '../NcRichText/autolink.js'
import Vue from 'vue'
import { RouterLink } from 'vue-router'

export default {
name: 'NcUserBubble',
Expand Down Expand Up @@ -262,8 +263,23 @@ export default {
return this.url && this.url.trim() !== ''
},

route() {
return getRoute(this.$router, this.url)
},

isLinkComponent() {
return this.hasUrl ? 'a' : 'div'
return this.hasUrl
? (this.route ? RouterLink : 'a')
: 'div'
},

linkAttrs() {
if (this.hasUrl) {
return this.route
? { to: this.route }
: { href: this.url }
}
return undefined
},

popoverEmpty() {
Expand Down

0 comments on commit 4eb1820

Please sign in to comment.