Canvas · Graphs and boards: Tab keeps a topic's words; the untested rules tested

Tab in a mind map topic being rewritten keeps the words and hands focus
back to the map; it asks for no child while the field is open, and the
map's keys wait for the field. Tests cover a new wire into a wired input
replacing the old, a connector released on its own shape linking
nothing, and a deleted whiteboard shape taking its links with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-09-27 08:35:08 -04:00
1 parent f3822a8d98
commit bd0285bd37
3 files changed
+80 -7

No files matched your search

+13 -2
View File
@@ -23,7 +23,7 @@ use crate::{
type OnTopic = Rc<dyn Fn(Option<&SharedString>, &mut Window, &mut App)>;
type OnKey = Rc<dyn Fn(&SharedString, &mut Window, &mut App)>;
/// Topics branching from a root on an endless plane, half to each side. A press selects a topic; arrows walk, Tab asks for a child, Enter for a sibling, Delete or Backspace to remove one, and F2 or a double press rewrites it; Escape lets the selection go, so Tab moves on. The owner keeps the map and answers each ask with `Topic::adding`, `removing` and `renaming`.
/// Topics branching from a root on an endless plane, half to each side. A press selects a topic; arrows walk, Tab asks for a child, Enter for a sibling, Delete or Backspace to remove one, and F2 or a double press rewrites it; Escape lets the selection go, so Tab moves on. While a topic is being rewritten its field takes every key; Tab keeps the words and hands focus back to the map. The owner keeps the map and answers each ask with `Topic::adding`, `removing` and `renaming`.
#[derive(IntoElement)]
pub struct MindMap {
id: ElementId,
@@ -245,7 +245,9 @@ impl RenderOnce for MindMap {
None => plane,
};
let (keys, tabbed, parent_of) = (placed.clone(), selected.clone(), self.root.clone());
let adding = on_add.clone();
let (adding, writing_tab, writing_keys) =
(on_add.clone(), editing.clone(), editing.clone());
let back = focus.clone();
div()
.id(id)
.track_focus(&focus)
@@ -256,6 +258,12 @@ impl RenderOnce for MindMap {
let (Some(key), Some(on_add)) = (&tabbed, &adding) else {
return;
};
if writing_tab.read(cx).field().is_some() {
cx.stop_propagation();
writing_tab.update(cx, |editing, cx| editing.finish(false, window, cx));
window.focus(&back);
return;
}
cx.stop_propagation();
log::info!("mind map: a child under {key}");
on_add(key, window, cx);
@@ -265,6 +273,9 @@ impl RenderOnce for MindMap {
let Some(at) = &selected else {
return;
};
if writing_keys.read(cx).field().is_some() {
return;
}
let key = event.keystroke.key.as_str();
match key {
"up" | "down" | "left" | "right" => {