From 31672b714d1d87cd14c01ecd7af5b8f1fb75d1e9 Mon Sep 17 00:00:00 2001 From: adlee-was-taken Date: Thu, 30 Apr 2026 20:22:06 -0400 Subject: [PATCH] fix(ext/vault): renderPane preserves in-memory newType when hash lacks /type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- extension/src/vault/vault.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extension/src/vault/vault.ts b/extension/src/vault/vault.ts index a651d03..32f4d0d 100644 --- a/extension/src/vault/vault.ts +++ b/extension/src/vault/vault.ts @@ -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':