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
This commit is contained in:
Kovid Goyal 2017-05-11 17:17:03 +05:30
parent 5b3d7c04cf
commit de6e5ec8d6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 11 additions and 0 deletions

View File

@ -349,6 +349,10 @@ class Overlay:
def container(self): def container(self):
return document.getElementById('book-overlay') return document.getElementById('book-overlay')
@property
def is_visible(self):
return self.container.style.display is not 'none'
def container_clicked(self, evt): def container_clicked(self, evt):
if self.panels.length and jstype(self.panels[-1].on_container_click) is 'function': if self.panels.length and jstype(self.panels[-1].on_container_click) is 'function':
self.panels[-1].on_container_click(evt) self.panels[-1].on_container_click(evt)

View File

@ -392,6 +392,13 @@ class View:
self.goto_named_destination(toc_node.dest, toc_node.frag) self.goto_named_destination(toc_node.dest, toc_node.frag)
def on_update_cfi(self, data): 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 self.currently_showing.bookpos = data.cfi
push_state(self.ui.url_data, replace=data.replace_history, mode=read_book_mode) push_state(self.ui.url_data, replace=data.replace_history, mode=read_book_mode)
username = get_interface_data().username username = get_interface_data().username