From bef9921a081ec2e2b56c1414bbd10e3364abd33d Mon Sep 17 00:00:00 2001
From: Henrik Askjer <henrik.askjer@uib.no>
Date: Mon, 27 Dec 2021 14:07:17 +0100
Subject: [PATCH] center definition if focused

---
 src/components/Article.vue | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/components/Article.vue b/src/components/Article.vue
index e6ed4536..2832ecca 100644
--- a/src/components/Article.vue
+++ b/src/components/Article.vue
@@ -131,7 +131,12 @@ export default {
   },
   mounted: function() {
     if (this.$route.hash == "#"+ this.title_id) {
-      document.getElementById(this.title_id).focus()
+      let focused = document.getElementById(this.title_id)
+      if (focused) focused.focus()
+    }
+    else if (this.$route.hash) {
+      let focused =document.getElementById(this.$route.hash.replace("#",""))
+      if (focused) focused.scrollIntoView({block: "center"})
     }
   },
   methods: {
-- 
GitLab