Hold back an inspector rebuild while a field in it has focus
A rebuild destroys the widget being typed in, and a typed value can change the very structure that decides whether a rebuild is needed -- a field that says how many ports a node has. That made such a field unusable: every keystroke previewed, the preview emitted 'project', refreshValues() saw the signature change and threw the row away. Dragging the value worked only because a drag keeps receiving globalpointermove on the destroyed widget. So refreshValues() now postpones a due rebuild while the focus sits inside the inspector, and runs it as soon as the field is left. Values are safe in the meantime: TextField.setValue ignores an edit in progress. Two handles for that in the toolkit. FocusManager.isWithin(node) also replaces the parent chain refreshLive() walked by hand, and changeHandlers lets a panel notice that the focus has gone -- there was no signal for that before. Nothing in the editor can trigger this today, since the Sequence setting that did is gone. It is the ground for the List tab, where a row that adds or deletes an item changes the structure while you type. The e2e check therefore builds the case out of real parts: type into a field, set the object's parent from outside -- the parent is part of the structure signature -- and confirm the input survives and the rebuild follows on Escape. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3c76106fd2
commit
5a440ba433
6 files changed
+73
-5
No files matched your search
@@ -9,6 +9,8 @@ import { collectFocusables, type Widget } from './Widget';
|
||||
export class FocusManager {
|
||||
/** Global handlers for keys nobody consumed (Delete, Ctrl+Z, …). */
|
||||
readonly globalHandlers: ((event: KeyboardEvent) => boolean)[] = [];
|
||||
/** Called after focus moved, so a panel can catch up on work it postponed while being typed in. */
|
||||
readonly changeHandlers: (() => void)[] = [];
|
||||
private focusedWidget: Widget | null = null;
|
||||
private readonly onKeyDown = (event: KeyboardEvent) => this.handleKeyDown(event);
|
||||
|
||||
@@ -26,6 +28,15 @@ export class FocusManager {
|
||||
this.focusedWidget = widget;
|
||||
previous?.onBlur();
|
||||
widget?.onFocus();
|
||||
for (const handler of this.changeHandlers) handler();
|
||||
}
|
||||
|
||||
/** Whether the focused widget is `node` or sits inside it. */
|
||||
isWithin(node: Container): boolean {
|
||||
for (let current: Container | null = this.focusedWidget; current; current = current.parent) {
|
||||
if (current === node) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
blur(): void {
|
||||
|
||||
Reference in new issue
Block a user