Skip to content

Commit

Permalink
Fix print button from collective landing page (Fixes: #280)
Browse files Browse the repository at this point in the history
Printing a collective from its landing page was broken as
`this.$router.push` detected navigating to the same route and aborted
the navigation. Let's catch this corner case and load subpages and
print screen nevertheless.
  • Loading branch information
mejo- committed Feb 8, 2022
1 parent 24c76c7 commit e5b847b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/components/Nav/CollectiveListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,21 @@ export default {
return this.collectiveParam === collective.name
},
showSubpagesAndPrint() {
this.show('subpages')
this.show('print')
},
print() {
this.$router.push(`/${encodeURIComponent(this.collective.name)}`,
() => {
this.show('subpages')
this.show('print')
() => this.showSubpagesAndPrint(),
(err) => {
// Navigation is aborted since navigating to same route, but we still want to print
if (err.name === 'NavigationDuplicated') {
this.showSubpagesAndPrint()
} else {
throw err
}
}
)
},
Expand Down
1 change: 1 addition & 0 deletions src/components/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export default {
this.$nextTick(() => {
window.print()
this.hide('print')
this.hide('subpages')
})
}
},
Expand Down

0 comments on commit e5b847b

Please sign in to comment.