Skip to content

FormAutocomplete clears dependent value on external dependency change (undo/redo, collab) #33

@d34dman

Description

@d34dman

Summary

FormAutocomplete.svelte:591-601 clears the field's value (onChange('')) whenever a params-mapped dependency field's value changes. The clearing logic can't distinguish "user changed the dependency" from "external state arrived" (undo, redo, programmatic reset, collaborative edit), so any external change to a dependency cascades a value-clear on the dependent field.

Same architectural smell as #31: child component unilaterally mutating parent state on a dependency signal it can't fully interpret.

Repro

  1. Configure a Jira create_issue node with dependent autocompletes: accountprojectissue_type.
  2. Open the node, select an account, then an issue_type. Workflow saves with both populated.
  3. Open the node config, change account to a different value. issue_type clears (user-driven, correct).
  4. Press Ctrl+Z. Store reverts account to the original. issue_type also clears — but it shouldn't, because the undone history snapshot had issue_type populated.

Net effect: undo of a dependency field corrupts the dependent field's value.

Why it's wrong

The child component is making a UI assumption ("the dependency changed → my value is stale") that doesn't hold when the dependency change comes from outside the form. The fingerprint diff in prevDepFingerprint only detects that the dependency changed, not who changed it.

Possible directions

  1. Drop the value-clear from FormAutocomplete entirely. Keep the UI-state reset (abort fetch, clear suggestions cache) — that's genuinely the child's concern. Move the value-clear to the parent: a consumer that wants "when account changes, clear issue_type" can declare it explicitly (e.g. via a schema-level clearOnChange: ['account'] field, or by handling it in onChange). This is the architecturally clean answer but is a behavior change for existing consumers.

  2. Opt-out flag. Add clearOnDependencyChange?: boolean to AutocompleteConfig, defaulting to true for back-compat. Node authors who store dependent values opt out.

  3. Distinguish user-driven from external dependency changes. Track a "user just interacted with sibling" signal in the form context. Only fire the clear when the dependency change is preceded by sibling-focus. Brittle.

(1) is what I'd want for v2. (2) is shippable on v1.x as an escape hatch.

Scope

(1) is a v2-shaped change: invasive for current consumers. (2) is ~20 lines plus docs.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions