diff --git a/ChangeLog.md b/ChangeLog.md index 2f6c917..f5435fd 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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 diff --git a/src/braindrop/app/screens/main.py b/src/braindrop/app/screens/main.py index ea6324d..d629391 100644 --- a/src/braindrop/app/screens/main.py +++ b/src/braindrop/app/screens/main.py @@ -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: