Explorar o código

fix e4b075cb: restore scroll only when closing editor

tophf hai 2 meses
pai
achega
be34e25c07
Modificáronse 1 ficheiros con 11 adicións e 8 borrados
  1. 11 8
      src/options/views/tab-installed.vue

+ 11 - 8
src/options/views/tab-installed.vue

@@ -447,9 +447,10 @@ async function onHashChange() {
   const script = newData ? newData.script : +id && getCurrentList().find(s => s.props.id === +id);
   const scrollElem1 = scroller.value;
   const scrollElem2 = document.scrollingElement; // for compact layout
-  const shouldSaveScroll = script && !state.script; // going into editor
-  scrollTop1 = shouldSaveScroll && scrollElem1[kScrollTop];
-  scrollTop2 = shouldSaveScroll && scrollElem2[kScrollTop];
+  if (script && !state.script) { // going into editor
+    scrollTop1 = scrollElem1[kScrollTop];
+    scrollTop2 = scrollElem2[kScrollTop];
+  }
   if (script) {
     state.code = newData ? newData.code : await sendCmdDirectly('GetScriptCode', id);
     state.script = script;
@@ -464,11 +465,13 @@ async function onHashChange() {
     loadData();
   }
   renderScripts();
-  state.script = null;
-  nextTick(() => { // scroll position has to be restored explicitly in Chrome and Firefox Android
-    scrollElem1[kScrollTop] = scrollTop1;
-    scrollElem2[kScrollTop] = scrollTop2;
-  });
+  if (state.script) {
+    state.script = null;
+    nextTick(() => { // scroll position has to be restored explicitly in Chrome and Firefox Android
+      scrollElem1[kScrollTop] = scrollTop1;
+      scrollElem2[kScrollTop] = scrollTop2;
+    });
+  }
 }
 async function renderScripts() {
   if (!store.canRenderScripts