From 335ded4b0a05743de9c9bdb1550227ec5d29c3be Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 08:27:23 -0800 Subject: [PATCH] Learn: a click on the shown tab runs no command A click on the For you or Skills tab the panel already shows ran learn.tab although the view did not change. The tab buttons now run it only for the other tab. --- crates/ui-egui/src/panels/learn.rs | 2 +- crates/ui-egui/src/panels/learn/tests.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/panels/learn.rs b/crates/ui-egui/src/panels/learn.rs index bb9b68e86a..82e139e25c 100644 --- a/crates/ui-egui/src/panels/learn.rs +++ b/crates/ui-egui/src/panels/learn.rs @@ -60,7 +60,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { let mut chosen = None; ui.horizontal(|ui| { for ((tab, name), label) in TABS.into_iter().zip([tl!("For you"), tl!("Skills")]) { - if ui.selectable_label(app.ui.learn.tab == tab, label).clicked() { + if ui.selectable_label(app.ui.learn.tab == tab, label).clicked() && app.ui.learn.tab != tab { chosen = Some(name); } } diff --git a/crates/ui-egui/src/panels/learn/tests.rs b/crates/ui-egui/src/panels/learn/tests.rs index 82bd0e454d..319ca1decf 100644 --- a/crates/ui-egui/src/panels/learn/tests.rs +++ b/crates/ui-egui/src/panels/learn/tests.rs @@ -523,6 +523,19 @@ fn the_tabs_rows_and_back_run_their_commands() { press(&mut app, "Back", View { tab: Tab::Skills, skill: None, tutorial: None }); } +/// A click on the tab the panel already shows runs no command. +#[test] +fn a_click_on_the_shown_tab_runs_no_command() { + let mut app = app(); + let ctx = context(); + for name in ["Skills", "For you"] { + click(&mut app, &ctx, name, show); + let commands = app.run_count; + click(&mut app, &ctx, name, show); + assert_eq!(app.run_count, commands, "{name}"); + } +} + /// `learn.tab` switches tabs and keeps what the Skills tab had open; `learn.skill` opens a skill's /// tutorials and answers the skill as `learn.list` lists it; `learn.back` goes up one level and /// keeps the view on the list of skills and on the For you tab.