From de6e5ec8d651949505cc1ff7ced33f0e5f0648db Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 11 May 2017 17:17:03 +0530 Subject: [PATCH] Workaround for bug on Chrome on Android that made typing in the viewer preferences impossible Chrome resizes the viewport when the on screen keyboard is opened. This causes the overlay to be closed. Hopefully, it will be fixed soon. See https://bugs.chromium.org/p/chromium/issues/detail?id=404315 --- src/pyj/read_book/overlay.pyj | 4 ++++ src/pyj/read_book/view.pyj | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/pyj/read_book/overlay.pyj b/src/pyj/read_book/overlay.pyj index 30934cf4f8..8cfd98ac6e 100644 --- a/src/pyj/read_book/overlay.pyj +++ b/src/pyj/read_book/overlay.pyj @@ -349,6 +349,10 @@ class Overlay: def container(self): return document.getElementById('book-overlay') + @property + def is_visible(self): + return self.container.style.display is not 'none' + def container_clicked(self, evt): if self.panels.length and jstype(self.panels[-1].on_container_click) is 'function': self.panels[-1].on_container_click(evt) diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index 82300749ae..e5fc039352 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -392,6 +392,13 @@ class View: self.goto_named_destination(toc_node.dest, toc_node.frag) def on_update_cfi(self, data): + if self.overlay.is_visible: + # Chrome on Android stupidly resizes the viewport when the on + # screen keyboard is displayed. This means that the push_state() + # below causes the overlay to be closed, making it impossible to + # type anything into text boxes. + # See https://bugs.chromium.org/p/chromium/issues/detail?id=404315 + return self.currently_showing.bookpos = data.cfi push_state(self.ui.url_data, replace=data.replace_history, mode=read_book_mode) username = get_interface_data().username