From 5db6dcbb0b3cfc797396b7587d2b258b5bea5397 Mon Sep 17 00:00:00 2001 From: Anthony Kinsey Date: Tue, 9 Nov 2021 11:34:49 -1000 Subject: [PATCH] feat: dont scroll when quoting posts, just highlight --- src/router/index.js | 2 +- src/views/Posts.vue | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 4e44dbd2..a7d5c729 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -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'}) }) diff --git a/src/views/Posts.vue b/src/views/Posts.vue index 31608180..992d7ed4 100644 --- a/src/views/Posts.vue +++ b/src/views/Posts.vue @@ -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 } @@ -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