fix(ext/popup): preserve unsupported-kind fields + totp expanded state

Two fixes from the T3+T4 code review:

C1 (Critical): renderSectionBlock previously rendered all fields
regardless of kind. For fields with kind url/date/month_year/totp/etc.
(from CLI-created items), the editor showed a blank value input; if
the user typed anything, the input handler cast the kind to the
wrong thing and silently overwrote the structured value with a
string — destroying data. Fix: filter editor to supported kinds
(text/password/concealed); key data-* attributes by field.id (not
by index) so handlers look up the correct field regardless of what
the render loop emitted. Unsupported-kind fields survive save
untouched. A small muted note "N fields of unsupported kind (edit
via CLI)" flags preserved entries. +2 tests.

I1 (Important): totp.ts's kind-toggle reRender read the module-
scope sectionsExpanded flag which was only updated on structural
mutations — so toggling the disclosure open without adding/removing
anything left the flag stale, and clicking Random/BIP39 collapsed
the disclosure. Fix: read data-expanded from the live DOM before
innerHTML swap.
This commit is contained in:
adlee-was-taken
2026-04-24 18:51:23 -04:00
parent e1d32b0379
commit 6ba9ccfa4c
5 changed files with 98 additions and 29 deletions

View File

@@ -566,6 +566,10 @@ textarea {
background: transparent; border: 0; color: #f85149;
cursor: pointer; font-size: 14px; padding: 0 4px;
}
.section-editor__preserved {
font-size: 10px; color: #6e7681; font-style: italic;
padding: 4px 0 4px 6px;
}
.section-editor__add {
display: flex; gap: 6px; margin-top: 6px;