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.
This commit is contained in:
dotCooCoo
2026-11-14 08:27:23 -08:00
parent 745dccb376
commit 335ded4b0a
2 changed files with 14 additions and 1 deletions
+1 -1
View File
@@ -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);
}
}
+13
View File
@@ -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.