Skip to content

bug: multi-select parameter search input stutters/closes during WebSocket re-evaluation #25695

Open

Description

@uzair-coder07

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When using a multi-select dynamic parameter with a static options list on the Create Workspace page, the combobox search input stutters or closes the dropdown while the user is typing or selecting options. This interrupts the search flow and forces users to re-open the dropdown and retype their query.

The issue occurs because every parameter value change triggers an immediate WebSocket round-trip (0ms debounce for non-text parameters), and the resulting re-render can cause the MultiSelectCombobox's onBlur handler to fire, closing the dropdown and resetting the search state.

Expected Behavior

Typing in the multi-select combobox search input should remain smooth and uninterrupted. The dropdown should stay open and the search text should be preserved while WebSocket re-evaluation responses arrive, especially when the options list is static and unchanged.

Steps to Reproduce

  1. Create a template with a multi-select dynamic parameter that has many static options (10+)
  2. Navigate to the Create Workspace page for that template
  3. Click on the multi-select field to open the combobox dropdown
  4. Start typing to filter the options
  5. While typing or after selecting an option, observe the dropdown may close or the search input may reset

Root Cause Analysis

The issue involves three interacting code paths:

1. Zero debounce for non-text parameters (CreateWorkspacePageView.tsx, lines 247-258):

// Return a debounce for string fields (those that involve typing) and
// zero debounce for all others (so the UI can react immediately).
return parameters.some(
  ({ parameter }) =>
    parameter.form_type === "input" || parameter.form_type === "textarea",
)
  ? 500
  : 0;

Multi-select selection changes send WebSocket messages immediately.

2. No memoization of options arrays (DynamicParameter.tsx, lines 367-395):
On every render, DynamicParameter creates new options and selectedOptions arrays via .map(), with no useMemo. These new references propagate to MultiSelectCombobox and trigger its internal options-sync effect (which compares via JSON.stringify, avoiding unnecessary state updates for static lists, but still runs the effect).

3. Blur-to-close behavior (MultiSelectCombobox.tsx, lines 544-547):

onBlur={(event) => {
  if (!onScrollbar) {
    setOpen(false);
  }
  ...
}}

If a parent re-render causes a brief focus loss on the CommandPrimitive.Input, onBlur fires and closes the dropdown. There is no protection against re-render-induced blur events.

Related Issues

Possible Fix Directions

  • Memoize options and selectedOptions arrays in DynamicParameter.tsx to stabilize references
  • Add re-render-aware blur handling in MultiSelectCombobox (e.g., use relatedTarget to distinguish user-initiated blur from React re-render blur)
  • Consider skipping the WebSocket send when the changed value doesn't affect other parameters (static list optimization)

Coder Version

Latest main (5ab5e07012, May 26, 2026)

Deployment

Coder on Kubernetes (but reproducible on any deployment)

Note: This issue was filed by Coder Agents on behalf of @uzair-coder07.

Activity

  1. added
    site
    parameters
    on May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugparameterssite

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions