Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus the tab and allow pageless redirect for notification.onclick #1448

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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