From f83e99c9b59130f2bae5fb0dacd30aea12244c9a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 9 Sep 2019 16:18:32 +0530 Subject: [PATCH] Preserve scroll position in list of keyboard shortcuts when customizing a shortcut --- src/pyj/read_book/prefs/keyboard.pyj | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pyj/read_book/prefs/keyboard.pyj b/src/pyj/read_book/prefs/keyboard.pyj index da3c195e5a..6012f217c5 100644 --- a/src/pyj/read_book/prefs/keyboard.pyj +++ b/src/pyj/read_book/prefs/keyboard.pyj @@ -63,6 +63,12 @@ def key_widget(key): def close_customize_shortcut(apply_changes): container = get_container() container.firstChild.style.display = 'block' + if close_customize_shortcut.shortcut_being_customized: + for item in container.firstChild.querySelectorAll('[data-user-data]'): + q = JSON.parse(item.dataset.userData) + if q.name is close_customize_shortcut.shortcut_being_customized: + item.scrollIntoView() + break container.lastChild.style.display = 'none' if apply_changes: shortcuts = v'[]' @@ -110,6 +116,7 @@ def customize_shortcut(sc_name): container = get_container() container.firstChild.style.display = 'none' container.lastChild.style.display = 'block' + close_customize_shortcut.shortcut_being_customized = sc_name shortcuts = v'[]' for item in container.querySelectorAll('[data-user-data]'): q = JSON.parse(item.dataset.userData)