Skip to content

Commit

Permalink
Simplify auto focus code.
Browse files Browse the repository at this point in the history
Related comments: #2581.
  • Loading branch information
rodrigogiraoserrao committed May 17, 2023
1 parent 4b22234 commit 765c7ce
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/textual/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,15 +669,10 @@ def _on_screen_resume(self) -> None:
self._refresh_layout(size, full=True)
self.refresh()
if self.AUTO_FOCUS is not None and self.focused is None:
try:
focus_candidates = self.query(self.AUTO_FOCUS)
except NoMatches:
pass
else:
for widget in focus_candidates:
if widget.focusable:
self.set_focus(widget)
break
for widget in self.query(self.AUTO_FOCUS):
if widget.focusable:
self.set_focus(widget)
break

def _on_screen_suspend(self) -> None:
"""Screen has suspended."""
Expand Down

0 comments on commit 765c7ce

Please sign in to comment.