Skip to content

Commit

Permalink
🔀 Merge pull request #117 from davep/details-close-focus-fix
Browse files Browse the repository at this point in the history
Fix focus getting lost when the details panel is closed
  • Loading branch information
davep authored Jan 20, 2025
2 parents 7b2a9c4 + bea2d71 commit 2571ea3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
editing dialog now style locally-known tags differently from suggestions
that haven't ever been used by the user.
([#115](https://github.com/davep/braindrop/pull/115))
- Fixed focus getting lost for a moment if it was within the details panel
and the details panel was closed.
([#114](https://github.com/davep/braindrop/issues/114))

## v0.6.1

Expand Down
11 changes: 10 additions & 1 deletion src/braindrop/app/screens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,17 @@ def action_escape_command(self) -> None:
def action_details_command(self) -> None:
"""Toggle the details of the raindrop details view."""
self.toggle_class("details-hidden")
if (
hidden := self.has_class("details-hidden")
and self.focused is not None
and self.query_one(RaindropDetails) in (self.focused, self.focused.parent)
):
# Focus was on the details, or within, so let's ensure it heads
# back to the list of raindrops as that feels like the most
# logical landing point.
self.set_focus(self.query_one(RaindropsView))
with update_configuration() as config:
config.details_visible = not self.has_class("details-hidden")
config.details_visible = not hidden

@on(CompactMode)
def action_compact_mode_command(self) -> None:
Expand Down

0 comments on commit 2571ea3

Please sign in to comment.