Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix focus getting lost when the details panel is closed #117

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading