From b25d0b5ff7191ee4f92a75d3a090e82c7de17fc7 Mon Sep 17 00:00:00 2001 From: Shehriyar Qureshi Date: Tue, 4 Mar 2025 14:50:54 +0500 Subject: [PATCH 1/3] fix(app): close selected preview on single click set context_page to preview with Some(entity) instead of None when "Show details" is selected. Preview of None entity would fail first equality check in Message::ToggleContextPage as `Preview(None, ..) != Preview(Some, ..)` . This fixes the two clicks needed to close Preview of Selected as first click would update self.context_page from Preview(None,..) to Preview(Some,..) and next click would pass equality and close Preview. --- src/app.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index c99aed4..d37e721 100644 --- a/src/app.rs +++ b/src/app.rs @@ -2704,7 +2704,7 @@ impl Application for App { match self.mode { Mode::App => { let show_details = !self.config.show_details; - self.context_page = ContextPage::Preview(None, PreviewKind::Selected); + self.context_page = ContextPage::Preview(entity_opt, PreviewKind::Selected); self.core.window.show_context = show_details; return cosmic::task::message(Message::SetShowDetails(show_details)); } From 1c6c93c130f53045bb2b491c62299ef1081df9e1 Mon Sep 17 00:00:00 2001 From: Shehriyar Qureshi Date: Tue, 4 Mar 2025 16:54:13 +0500 Subject: [PATCH 2/3] Revert "fix(app): close selected preview on single click" This reverts commit b25d0b5ff7191ee4f92a75d3a090e82c7de17fc7. --- src/app.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index d37e721..c99aed4 100644 --- a/src/app.rs +++ b/src/app.rs @@ -2704,7 +2704,7 @@ impl Application for App { match self.mode { Mode::App => { let show_details = !self.config.show_details; - self.context_page = ContextPage::Preview(entity_opt, PreviewKind::Selected); + self.context_page = ContextPage::Preview(None, PreviewKind::Selected); self.core.window.show_context = show_details; return cosmic::task::message(Message::SetShowDetails(show_details)); } From eaef4109391e482247df2f5a0deff14da0ea03ab Mon Sep 17 00:00:00 2001 From: Shehriyar Qureshi Date: Tue, 4 Mar 2025 16:54:38 +0500 Subject: [PATCH 3/3] fix(app): close preview on single click match on Preview (the type) to close preview context in single click. matching on Preview type prevents the equality check failing b/w ContextPage::Preview(Some,_) and ContextPage::Preview(None,_) --- src/app.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index c99aed4..4e520cc 100644 --- a/src/app.rs +++ b/src/app.rs @@ -3097,7 +3097,9 @@ impl Application for App { } Message::ToggleContextPage(context_page) => { //TODO: ensure context menus are closed - if self.context_page == context_page { + if self.context_page == context_page + || matches!(self.context_page, ContextPage::Preview(_, _)) + { self.set_show_context(!self.core.window.show_context); } else { self.set_show_context(true);