mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-15 08:45:25 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user