From a327eed2c3fd47eefe3be9e284a54d5a4dfc31bb Mon Sep 17 00:00:00 2001
From: Gnome Ann <>
Date: Mon, 27 Sep 2021 17:44:22 -0400
Subject: [PATCH] Fix editor scrolling issues
---
aiserver.py | 2 +-
static/application.js | 12 +++++++-----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/aiserver.py b/aiserver.py
index d5f3fd86..dd7bd435 100644
--- a/aiserver.py
+++ b/aiserver.py
@@ -1476,7 +1476,7 @@ def update_story_chunk(idx: Union[int, str]):
item = vars.acregex_ui.sub('\\1', item) # Add special formatting to adventure actions
chunk_text = f'{formatforhtml(item)}'
- emit('from_server', {'cmd': 'updatechunk', 'data': {'index': idx, 'html': chunk_text, 'last': (idx == (vars.actions.get_last_key() if len(vars.actions) else 0))}}, broadcast=True)
+ emit('from_server', {'cmd': 'updatechunk', 'data': {'index': idx, 'html': chunk_text}}, broadcast=True)
#==================================================================#
diff --git a/static/application.js b/static/application.js
index e9156158..8eb3bc5d 100644
--- a/static/application.js
+++ b/static/application.js
@@ -947,6 +947,12 @@ function chunkOnSelectionChange(event) {
syncAllModifiedChunks();
setTimeout(function() {
highlightEditingChunks();
+ // Attempt to prevent Chromium-based browsers on Android from
+ // scrolling away from the current selection
+ setTimeout(function() {
+ game_text.blur();
+ game_text.focus();
+ }, 144);
}, 2);
}, 2);
}
@@ -1096,7 +1102,7 @@ $(document).ready(function(){
scrollToBottom();
} else if(msg.cmd == "updatechunk") {
hideMessage();
- const {index, html, last} = msg.data;
+ const {index, html} = msg.data;
const existingChunk = game_text.children(`#n${index}`)
const newChunk = $(html);
unbindGametext();
@@ -1110,10 +1116,6 @@ $(document).ready(function(){
}
bindGametext();
hide([$('#curtain')]);
- if(last) {
- // Scroll to bottom of text if it's the last element
- scrollToBottom();
- }
} else if(msg.cmd == "removechunk") {
hideMessage();
let index = msg.data;