Skip to content

Support dependent autocomplete fields via params mapping #28

@stmh

Description

@stmh

Problem

When a config schema has multiple autocomplete fields where one depends on another's value (e.g., selecting a Jira project first, then filtering issue types by that project), there's no way to pass the current value of one field as a query parameter to another field's autocomplete URL.

Currently, FormAutocomplete only passes the search term (q) as a query parameter. The URL is fully static.

Use Case

The Jira integration in flowdrop-rs has these config fields:

  1. account - autocomplete selecting a Jira account secret
  2. project - autocomplete listing projects (needs account to authenticate)
  3. issue_type - autocomplete listing issue types (needs account + project)
  4. assignee - autocomplete searching users (needs account + project)

The backend endpoints in flowdrop-rs are ready:

  • GET /api/flowdrop/jira/projects?account={account}
  • GET /api/flowdrop/jira/issue-types?account={account}&project={project}
  • GET /api/flowdrop/jira/users?account={account}&project={project}&q={query}

But the frontend can't pass the selected account and project values to these URLs.

Proposed Solution

Add an optional params field to AutocompleteConfig:

interface AutocompleteConfig {
  url: string;
  // ... existing fields ...
  
  /** Map of URL query parameter names to config field names.
   *  When fetching autocomplete options, the current value of
   *  each referenced field is appended as a query parameter.
   *  
   *  Example: { "account": "account", "project": "project" }
   *  If the "account" field has value "my-jira", the fetch URL becomes:
   *  /api/flowdrop/jira/issue-types?account=my-jira&q=...
   */
  params?: Record<string, string>;
}

In FormAutocomplete, when building the fetch URL, iterate over params and append each mapped field's current value from the form state.

Bonus: Reactive refresh

When a dependency field value changes (e.g., user selects a different project), the dependent autocomplete should:

  1. Clear its current value (since it may no longer be valid)
  2. Refetch options on next focus

Backend Type (already in place)

The Rust AutocompleteConfig struct in flowdrop-rs would add:

pub params: Option<HashMap<String, String>>,

Context

This was identified during the implementation of Jira integration node types (flowdrop-rs 005-jira-node-types). The backend proxy endpoints and node config schemas are ready — only the frontend parameter passing is missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions