fix(pages): Delete that removes an interaction ends the Pages list focus

This commit is contained in:
AganzeFelicite
2026-10-19 12:50:43 +02:00
parent 3e83ae44b7
commit 6e7b63bc16
2 changed files with 25 additions and 0 deletions
+23
View File
@@ -304,3 +304,26 @@ fn escape_closes_prototype_editor_without_deselecting_layer() {
u.key(pos2(100.0, 100.0), egui::Key::Escape);
assert!(u.app.session.selection().is_empty(), "selection cleared on third escape");
}
/// After a click in the Pages list, Delete that removes an interaction ends the list's hold on the
/// keyboard: with the layer deselected afterwards, Delete doesn't take the page (#859).
#[test]
fn deleting_an_interaction_ends_the_pages_list_focus() {
let (s, _a, _b, btn) = setup();
let mut u = Ui::new(s);
let first = u.app.session.page().unwrap();
u.run("page.add", json!({}));
u.run("page.select", json!({"id": first}));
// As after a click on the page's row (layers_keys_tests clicks the real row).
u.app.ui.pages_focus = u.app.session.ds().ok().map(|d| d.uid);
u.app.ui.right_tab = crate::RightTab::Prototype;
u.run("select.set", json!({"ids": [btn]}));
crate::proto_panel::open_editor(&u.ctx, Some((btn, 0)));
u.frames(1, Vec::new);
u.key(pos2(100.0, 100.0), egui::Key::Delete);
assert_eq!(u.app.session.doc().unwrap().node(btn).unwrap().interactions.len(), 0);
assert!(u.app.ui.pages_focus.is_none());
u.run("select.none", json!({}));
u.key(pos2(100.0, 100.0), egui::Key::Delete);
assert_eq!(u.app.session.doc().unwrap().pages.len(), 2, "the page stays");
}
+2
View File
@@ -53,6 +53,8 @@ pub fn delete_selected_interaction(app: &mut FigApp, ctx: &egui::Context) -> boo
return false;
}
open_editor(ctx, None);
// Delete went to the interaction, so a later one doesn't go to the Pages list.
app.ui.pages_focus = None;
let ids = targets_for(app, node);
app.run("proto.interaction.remove", json!({"ids": ids, "index": index}));
true