Rename box: Tab (and leaving the box) keeps the new name (#3313) (#3336)

* claim: #3313

* fix(ui): the Rename box keeps the new name when it loses focus (#3313)

Only Enter committed a rename: Tab (and anything else that moved focus away)
dropped the typed name. Leaving the box now keeps it, as a click elsewhere
already did; Escape still cancels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: bherbruck <brennen.herbruck@gmail.com>
This commit is contained in:
DuBearte
2026-10-21 22:07:38 +00:00
committed by GitHub
parent 14b27f323a
commit 95b23f28d6
2 changed files with 37 additions and 1 deletions
+35
View File
@@ -848,6 +848,41 @@ fn menus_near_the_window_corner_open_inward() {
}
}
/// #3313: renaming a body by typing in the Rename box and pressing Enter (or Tab) renames it.
#[test]
fn typing_a_new_body_name_and_enter_renames_it() {
for confirm in ["Enter", "Tab"] {
let mut h = crate::scenario::Harness::new();
h.app.run("solid.box", json!({"length": 10, "width": 10, "height": 10})).unwrap();
let b = h.app.session.model.state().bodies[0].name.clone();
h.app.run("select.set", json!({"items": [{"type": "body", "name": b}]})).unwrap();
h.frames(2);
h.step(&json!({"key": "F2"})).unwrap();
h.frames(2);
assert!(h.app.menu.rename.is_some(), "F2 opens the Rename box");
h.step(&json!({"text": "Lid"})).unwrap();
h.frames(1);
h.step(&json!({"key": confirm})).unwrap();
h.frames(2);
let names: Vec<String> = h.app.session.model.state().bodies.iter().map(|b| b.name.clone()).collect();
assert_eq!(names, ["Lid"], "{confirm} renames the body; status {:?}", h.app.status);
}
// Escape still cancels.
let mut h = crate::scenario::Harness::new();
h.app.run("solid.box", json!({"length": 10, "width": 10, "height": 10})).unwrap();
let b = h.app.session.model.state().bodies[0].name.clone();
h.app.run("select.set", json!({"items": [{"type": "body", "name": b.clone()}]})).unwrap();
h.frames(2);
h.step(&json!({"key": "F2"})).unwrap();
h.frames(2);
h.step(&json!({"text": "Lid"})).unwrap();
h.frames(1);
h.step(&json!({"key": "Escape"})).unwrap();
h.frames(2);
assert!(h.app.menu.rename.is_none());
assert_eq!(h.app.session.model.state().bodies[0].name, b, "Escape keeps the old name");
}
#[test]
fn contribution_picked_faces_open_their_own_feature_after_later_modifiers() {
use solidcraft_engine::{Sel, geom::Vec3};
+2 -1
View File
@@ -375,7 +375,8 @@ pub(crate) fn rename_menu(ui: &mut Ui, value: &mut String, focused: &mut bool) -
response.request_focus();
*focused = true;
}
if ui.input(|i| i.key_pressed(egui::Key::Enter)) {
// Leaving the box with Tab keeps the new name as Enter does; only Escape cancels (#3313).
if ui.input(|i| i.key_pressed(egui::Key::Enter)) || (response.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Tab))) {
done = Some(true);
}
if ui.input(|i| i.key_pressed(egui::Key::Escape)) {