Skip to content

Commit

Permalink
🐛 Fix focus getting lost when the details panel is closed
Browse files Browse the repository at this point in the history
Fixes #114.
  • Loading branch information
davep committed Jan 20, 2025
1 parent 7b2a9c4 commit 2a3069e
Show file tree
Hide file tree
Showing 2 changed files with 16 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
14 changes: 13 additions & 1 deletion src/braindrop/app/screens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,20 @@ 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.focused is self.query_one(RaindropDetails)
or self.focused.parent is self.query_one(RaindropDetails)
)
):
# 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 2a3069e

Please sign in to comment.