Skip to content

Commit

Permalink
Merge pull request #1448 from nextcloud/bugfix/noid/focus-the-tab-and…
Browse files Browse the repository at this point in the history
…-allow-pageless-redirect-for-onclick

Focus the tab and allow pageless redirect for notification.onclick
  • Loading branch information
nickvergessen authored Feb 8, 2023
2 parents 898ad8b + d464a68 commit 5cb9cdc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions js/notifications-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/notifications-main.js.map

Large diffs are not rendered by default.

22 changes: 19 additions & 3 deletions src/Components/Notification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import RichText from '@nextcloud/vue-richtext'
import DefaultParameter from './Parameters/DefaultParameter.vue'
import File from './Parameters/File.vue'
import User from './Parameters/User.vue'
import { emit } from '@nextcloud/event-bus'
export default {
name: 'Notification',
Expand Down Expand Up @@ -329,9 +330,24 @@ export default {
})
if (this.link) {
n.onclick = function(event) {
event.preventDefault()
window.location.href = this.link
n.onclick = async function(e) {
const event = {
cancelAction: false,
notification: this.$props,
action: {
url: this.link,
type: 'WEB',
},
}
await emit('notifications:action:execute', event)
if (!event.cancelAction) {
console.debug('Redirecting because of a click onto a notification', this.link)
window.location.href = this.link
}
// Best effort try to bring the tab to the foreground (works at least in Chrome, not in Firefox)
window.focus()
}.bind(this)
}
},
Expand Down

0 comments on commit 5cb9cdc

Please sign in to comment.