Preserve in-progress form values across the dep detour#989
Conversation
dd23d21 to
f24d4b8
Compare
There was a problem hiding this comment.
Pull request overview
Preserves in-progress <esphome-add-component-form> values when the user detours via “+ Add ” to create a missing dependency, by snapshotting current form values in the dialog and reapplying them during reseed on return.
Changes:
- Add
restoredValuesplumbing from dialog → form →buildInitialValues()and overlay restored values beforeprefillReference. - Snapshot the form’s current values in
add-component-dialogwhen starting a dep detour. - Add/extend unit tests covering the restore-vs-prefill precedence.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/components/device/add-component-form-seed-fns.test.ts | Adds coverage for restored values overlay behavior and precedence vs prefillReference. |
| src/components/device/add-component-form.ts | Adds restoredValues input + exposes currentValues for the dialog snapshot. |
| src/components/device/add-component-form-seed.ts | Extends seeding context and overlays restored values before prefillReference. |
| src/components/device/add-component-dialog.ts | Captures and passes restored values during dep detours. |
|
|
esphbot
left a comment
There was a problem hiding this comment.
Blocking issues found.
_onBundleSelectedabandons the detour but leaves_returnValuesset, leaking stale values onto the bundle's first form- Cancelling the detour with Back discards the in-progress values the PR set out to preserve
|
Both lifecycle gaps fixed in 49b8054.
Added two tests pinning each: bundle-mid-detour clears the snapshot, and Back preserves it (restores |
|
Both fixes confirmed correct and tested. One residual leak remains on a symmetric path. Bundle-advance branch in |
|
|
esphbot
left a comment
There was a problem hiding this comment.
Blocking issues found.
_returnValuesleaks into the next bundle step after a mid-bundle dep detour
…he full lifecycle
|
Ran /simplify and tightened the
The |
PR Review — Preserve in-progress form values across the dep detourSolid, well-tested fix. The detour value-preservation lifecycle is now correct across every exit path; only two doc/defensive nits remain. What's done well:
What needs attention (both non-blocking):
🟢 Suggestions
1. buildInitialValues step-list docstring omits the new restore overlay
|
esphbot
left a comment
There was a problem hiding this comment.
No blocking issues found.
|
Addressed both remaining nits in 16009a1:
The earlier Copilot "_returnValues leaks into bundle-advance" note predates ecda9e3 — that path now explicitly clears the snapshot (with a test). Suite green (3991). |
What does this implement/fix?
When you fill some fields in the Add-component form (an SPI device's
cs_pin, line frequency, etc.) and then click "+ Add " to add a missing dependency, returning to the form wiped everything you had typed; the form re-mounts and re-seeds from scratch, carrying back only the new dependency's id reference.This snapshots the form's in-progress values when a "+ Add " detour starts (in the dialog, before the form unmounts) and overlays them on return via a new
restoredValuesstep inbuildInitialValues. The overlay lands after the seeded defaults and beforeprefillReference, so what you typed survives while the just-added dependency's id still wins for the reference field. The snapshot is only applied to the original form on return, not to the dependency's own form during the detour, so the dependency keeps its own auto-generated id (no id collision).This is the input-preservation half; the separate stale-pin-display issue (a pin select showing a value it never held after a detour) is fixed in #990.
Related issue or feature (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocsmaintenancecidependenciesFrontend coordination
Checklist
npm run lintpasses.npm run testpasses.