keyboard nav in tree view.

This commit is contained in:
Dustin Swan 2026-02-15 23:37:43 -07:00
parent 5c76f9f3a2
commit a8a51718fc
No known key found for this signature in database
GPG key ID: 30D46587E2100467
2 changed files with 73 additions and 26 deletions

View file

@ -6,6 +6,7 @@ type ComponentInstance = {
state: any;
update: (state: any) => (event: any) => any;
view: (state: any) => any;
focusable: boolean;
};
export function runAppCompiled(canvas: HTMLCanvasElement, store: any) {
@ -79,13 +80,15 @@ export function runAppCompiled(canvas: HTMLCanvasElement, store: any) {
instance = {
state: ui.init,
update: ui.update,
view: ui.view
view: ui.view,
focusable: ui.focusable?._tag === 'True'
};
componentInstances.set(fullKey, instance);
} else {
// refresh closures, pick up new values
instance.update = ui.update;
instance.view = ui.view;
instance.focusable = ui.focusable?._tag === 'True'
}
if (ui.autoFocus?._tag === 'True' && isNew) {
@ -209,6 +212,10 @@ export function runAppCompiled(canvas: HTMLCanvasElement, store: any) {
}
if (event._tag === 'ComponentEvent') {
const instance = componentInstances.get(event._0);
if (instance?.focusable) {
setFocus(event._0);
}
handleComponentEvent(event._0, event._1);
return;
}