mirror of
https://github.com/storytold/designcraft.git
synced 2026-12-02 20:21:15 -05:00
Merge pull request #3359 from storytold/fix/links-clear-empty-selection
Clear the Links selection when the list becomes empty
This commit is contained in:
1 file changed
+27
-4
@@ -583,10 +583,6 @@ mod framework {
|
||||
if unavailable && !rows.is_empty() {
|
||||
small(ui, None, &tr("Link status is unavailable."), Shade::Muted, None);
|
||||
}
|
||||
if rows.is_empty() {
|
||||
Text::new(tr("No placed graphics.")).shade(Shade::Muted).show(ui);
|
||||
return;
|
||||
}
|
||||
// The chosen row belongs to the document it was chosen in, and holds only while that document still lists it: a
|
||||
// row of another document, or one gone from this list, is no choice.
|
||||
let row_id = |r: &Value| r["asset"].as_u64().or_else(|| r["story"].as_u64());
|
||||
@@ -595,6 +591,10 @@ mod framework {
|
||||
if chosen.is_none() {
|
||||
ui.data_mut(|d| d.remove::<u64>(sel_key));
|
||||
}
|
||||
if rows.is_empty() {
|
||||
Text::new(tr("No placed graphics.")).shade(Shade::Muted).show(ui);
|
||||
return;
|
||||
}
|
||||
// Status and Page · PPI are as wide as their widest entry (a chip sized to its words, a short readout) and Name
|
||||
// takes the rest, so a file name stays readable and every column fits the panel; long source paths are cut.
|
||||
let width = ui.available_width();
|
||||
@@ -956,6 +956,29 @@ mod ui223_links_tests {
|
||||
assert_eq!(app.session.journal.last(), Some(&(command.to_owned(), payload)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ui223_links_empty_list_drops_the_selected_link_before_undo_restores_it() {
|
||||
let (app, items, assets) = graphics();
|
||||
let mut h = harness(app);
|
||||
click(&mut h, "studio-b/photo.svg");
|
||||
assert!(!button(&h, "Go To").facts.as_ref().unwrap().disabled);
|
||||
|
||||
let deleted = h.state_mut().run("edit.clear", json!({"ids": items})).unwrap();
|
||||
assert_eq!(deleted["deleted"], 3);
|
||||
idle(&mut h, 3);
|
||||
assert!(h.query_by_label("No placed graphics.").is_some());
|
||||
h.state_mut().run("edit.undo", json!({})).unwrap();
|
||||
idle(&mut h, 3);
|
||||
assert!(h.query_by_role_and_label(egui::accesskit::Role::Button, "studio-b/photo.svg").is_some(), "the same link has returned");
|
||||
assert!(h.query_by_label("Choose a link.").is_some(), "the empty list retired the old selection");
|
||||
assert!(h.query_by_label("Go To").is_none(), "restoring the links does not select one");
|
||||
|
||||
click(&mut h, "studio-b/photo.svg");
|
||||
let go = button(&h, "Go To");
|
||||
click_at(&mut h, go.rect);
|
||||
assert_last_command(h.state(), "links.goTo", json!({"asset": assets[1].0}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ui223_links_pointer_go_to_preserves_same_named_asset_identity() {
|
||||
let (app, items, assets) = graphics();
|
||||
|
||||
Reference in new issue
Block a user