fix(ext/vault): renderPane preserves in-memory newType when hash lacks /type

In the fullscreen UX, clicking '+ new item' set the hash to '#/add'
(no type) and called renderPane. The user then clicks a type button;
its handler calls setState({ newType: type }), which in vault.ts
triggers renderPane again. renderPane was unconditionally re-deriving
state.newType from the URL hash — clobbering the just-selected type
back to null. Result: the type-selection screen kept re-rendering and
no item could be created.

Fix: prefer route.type when present (deep-link case); otherwise keep
the in-memory state.newType. Same field order, same one-line touch.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
adlee-was-taken
2026-04-30 20:22:06 -04:00
parent f1ae5841bc
commit 31672b714d

View File

@@ -448,8 +448,10 @@ function renderPane(): void {
}
break;
case 'add':
// Sync newType from hash for the item-form component
state.newType = (route.type as ItemType) ?? null;
// Prefer hash type for deep-links; otherwise keep the in-memory value
// set by the type-selection click handler (which calls setState →
// renderPane before the URL hash has been updated to include the type).
state.newType = (route.type as ItemType) ?? state.newType ?? null;
renderItemForm(pane, 'add');
break;
case 'edit':