Repository navigation
Description
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
- Create a template with a
multi-selectdynamic parameter that has many static options (10+) - Navigate to the Create Workspace page for that template
- Click on the multi-select field to open the combobox dropdown
- Start typing to filter the options
- 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
- bug: WorkspaceParametersPage exhibits janky/flickering behavior when interacting with parameters #22028 (closed): Janky/flickering behavior on WorkspaceParametersPage (fixed for workspace settings page, same class of bug)
- #22029 (closed): Added debounce to
WorkspaceParametersPageViewExperimental - #22860/#22876 (closed via
4379f69627): Fixed stale WS responses from clobbering form input inuseSyncFormParameters - #18856: Slider lag from lack of debouncing (similar pattern)
Possible Fix Directions
- Memoize
optionsandselectedOptionsarrays inDynamicParameter.tsxto stabilize references - Add re-render-aware blur handling in
MultiSelectCombobox(e.g., userelatedTargetto 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