diff --git a/src/pyj/read_book/prefs/keyboard.pyj b/src/pyj/read_book/prefs/keyboard.pyj index 12256fc95e..773e2abf9d 100644 --- a/src/pyj/read_book/prefs/keyboard.pyj +++ b/src/pyj/read_book/prefs/keyboard.pyj @@ -84,7 +84,7 @@ def close_customize_shortcut(apply_changes): item.dataset.userData = JSON.stringify(q) break get_container().dataset.changed = 'true' - commit_keyboard(create_keyboard_panel.onchange) + commit_keyboard(create_keyboard_panel.onchange, None) def add_key_widget(): @@ -184,7 +184,7 @@ def shortcuts_differ(a, b): return False -def commit_keyboard(onchange): +def commit_keyboard(onchange, container): sd = get_session_data() vals = {} for item in get_container().querySelectorAll('[data-user-data]'): @@ -192,6 +192,7 @@ def commit_keyboard(onchange): if shortcuts_differ(q.shortcuts, shortcuts_definition()[q.name].shortcuts): vals[q.name] = q.shortcuts sd.set('keyboard_shortcuts', vals) - create_keyboard_panel.onchange = None + if container is not None: + create_keyboard_panel.onchange = None if get_container().dataset.changed is 'true': onchange()