When focusing iframe if the selection bar is visible focus that instead

This commit is contained in:
Kovid Goyal 2020-08-15 10:15:59 +05:30
parent 9eea78f092
commit 7edad3048e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 10 additions and 4 deletions

View File

@ -546,12 +546,15 @@ class SelectionBar:
if sd.get('show_selection_bar'):
self.container.style.display = 'block'
self.state = WAITING
self.container.focus()
self.focus()
@property
def is_visible(self):
return self.container.style.display is not 'none'
def focus(self):
self.container.focus()
def update_position(self, dragged_handle):
container = self.container
cs = self.view.currently_showing.selection
@ -718,7 +721,7 @@ class SelectionBar:
if not apply_changes:
self.state = WAITING
self.update_position()
self.container.focus()
self.focus()
return
ed = self.current_editor
self.current_editor = None
@ -731,7 +734,7 @@ class SelectionBar:
self.state = WAITING
self.update_position()
get_session_data().set('highlight_style', self.current_highlight_style.style)
self.container.focus()
self.focus()
def editor_container_clicked(self, ev):
ev.stopPropagation(), ev.preventDefault()

View File

@ -630,7 +630,10 @@ class View:
self.focus_iframe()
def focus_iframe(self):
self.iframe.contentWindow.focus()
if self.selection_bar.is_visible:
self.selection_bar.focus()
else:
self.iframe.contentWindow.focus()
def show_chrome(self, data):
elements = {}