Summary
A format: "autocomplete" field that declares a dependency via autocomplete.params loses its own value whenever the form is opened/loaded with values already populated (e.g. editing a saved record/node). The dependent field is cleared to '' before the user can save, so the value never round-trips.
Fields without params (non-dependent autocompletes) are unaffected.
Version: @flowdrop/flowdrop@1.13.0
Root cause
Both host forms initialise their internal values empty and only fill them from the values/config prop in a post-mount $effect:
SchemaForm.svelte — formValues = $state({}) then merge effect (Object.entries(schema.properties)...; formValues = mergedValues)
ConfigForm.svelte — configValues = $state({}) then merge effect (... configValues = mergedConfig)
Both expose the live state via setContext('flowdrop:getFormValues', () => …).
In FormAutocomplete.svelte:
// captured during component init — getFormValues() is still {} at this point
let prevDepFingerprint = depFingerprint; // => "{}"
$effect(() => {
const current = depFingerprint;
if (current === prevDepFingerprint) return;
prevDepFingerprint = current;
abortController?.abort();
suggestions = [];
labelCache = new Map();
if (multiple) onChange([]);
else onChange(''); // <-- wipes the dependent field's value
});
Mount/effect ordering (parent before child on initial flush):
- Host form sets
formValues = {}; children render.
- Dependent
FormAutocomplete captures prevDepFingerprint from the empty form → "{}".
- Host form's merge
$effect runs and populates the dependency value.
- The dependent field's fingerprint flips
"{}" → {"<param>":"<value>"}, the clearing effect fires, and onChange('') wipes the just-loaded value.
Reproduction
- Build a
SchemaForm (or ConfigForm) with two autocomplete fields where field B declares autocomplete.params: { someParam: "fieldA" }.
- Mount it with
values that already contain both fieldA and fieldB.
- Observe that
fieldB is cleared to '' shortly after mount, even though no user interaction occurred.
This also affects node configs in the editor: a saved node with a dependent autocomplete (e.g. a Jira create_issue node with issue_type, which depends on account/project) loses the dependent value when reopened. It typically goes unnoticed because nodes are usually filled from scratch (dependency-then-dependent), where clearing an already-empty field is a harmless no-op.
Expected behaviour
A dependent autocomplete should preserve its incoming value when the form loads. The clearing-on-dependency-change behaviour should only apply to a genuine user-driven change of the dependency, not to the initial empty→populated transition during form initialisation.
Suggested fix
Skip the clear when the fingerprint's first transition is from the empty-initial state — e.g. initialise prevDepFingerprint lazily once the host form's values have settled, or guard the clearing effect so it doesn't run on the initial "{}" → populated transition (only clear when the previous fingerprint was itself non-empty / derived from a real value).
Summary
A
format: "autocomplete"field that declares a dependency viaautocomplete.paramsloses its own value whenever the form is opened/loaded with values already populated (e.g. editing a saved record/node). The dependent field is cleared to''before the user can save, so the value never round-trips.Fields without
params(non-dependent autocompletes) are unaffected.Version:
@flowdrop/flowdrop@1.13.0Root cause
Both host forms initialise their internal values empty and only fill them from the
values/configprop in a post-mount$effect:SchemaForm.svelte—formValues = $state({})then merge effect (Object.entries(schema.properties)...; formValues = mergedValues)ConfigForm.svelte—configValues = $state({})then merge effect (... configValues = mergedConfig)Both expose the live state via
setContext('flowdrop:getFormValues', () => …).In
FormAutocomplete.svelte:Mount/effect ordering (parent before child on initial flush):
formValues = {}; children render.FormAutocompletecapturesprevDepFingerprintfrom the empty form →"{}".$effectruns and populates the dependency value."{}"→{"<param>":"<value>"}, the clearing effect fires, andonChange('')wipes the just-loaded value.Reproduction
SchemaForm(orConfigForm) with two autocomplete fields where field B declaresautocomplete.params: { someParam: "fieldA" }.valuesthat already contain bothfieldAandfieldB.fieldBis cleared to''shortly after mount, even though no user interaction occurred.This also affects node configs in the editor: a saved node with a dependent autocomplete (e.g. a Jira
create_issuenode withissue_type, which depends onaccount/project) loses the dependent value when reopened. It typically goes unnoticed because nodes are usually filled from scratch (dependency-then-dependent), where clearing an already-empty field is a harmless no-op.Expected behaviour
A dependent autocomplete should preserve its incoming value when the form loads. The clearing-on-dependency-change behaviour should only apply to a genuine user-driven change of the dependency, not to the initial empty→populated transition during form initialisation.
Suggested fix
Skip the clear when the fingerprint's first transition is from the empty-initial state — e.g. initialise
prevDepFingerprintlazily once the host form's values have settled, or guard the clearing effect so it doesn't run on the initial"{}"→ populated transition (only clear when the previous fingerprint was itself non-empty / derived from a real value).