Skip to content

Commit

Permalink
feat: dont scroll when quoting posts, just highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
akinsey committed Nov 9, 2021
1 parent fd24e92 commit 5db6dcb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const router = createRouter({
history: createWebHistory(),
routes,
scrollBehavior(to) {
if (to.hash) {
if (to.hash && !to.params.saveScrollPos) {
nextTick(() => {
document.getElementById(to.hash.substring(1)).scrollIntoView({behavior: 'smooth'})
})
Expand Down
4 changes: 2 additions & 2 deletions src/views/Posts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ export default {
quote += '[/quote]'
v.quote = post
v.quote.body = quote
$router.push({ path: $route.path, query: $route.query, hash: `#${post.id}` })
$router.replace({ name: $route.name, query: $route.query, hash: `#${post.id}`, params: { ...$route.params, saveScrollPos: true } })
delete v.quote.id
v.showEditor = true
}
Expand All @@ -902,7 +902,7 @@ export default {
quote += ' date=' + new Date(post.created_at).getTime() + ']'
quote += post.body || post.body_html
quote += '[/quote]'
$router.push({ path: $route.path, query: $route.query, hash: `#${post.id}` })
$router.replace({ name: $route.name, query: $route.query, hash: `#${post.id}`, params: { ...$route.params, saveScrollPos: true } })
let copyText = decode(quote)
// create temp element
Expand Down

0 comments on commit 5db6dcb

Please sign in to comment.