Skip to content

refactor(site): convert OrganizationAutocomplete to a fully controlled component #1440

@johnstcn

Description

@johnstcn

Context

OrganizationAutocomplete currently manages its own selected state internally and exposes an onChange callback. PR coder/coder#23906 added an organizationId prop with render-time derivation to support controlled pre-selection, but the component is still a hybrid controlled/uncontrolled component.

Every other autocomplete/select component in the codebase (Autocomplete, UserAutocomplete, SelectFilter, MultiUserSelect) is fully controlled: the parent owns the value, and the component just renders and calls onChange.

Proposal

Refactor OrganizationAutocomplete to match the fully controlled pattern:

  • Accept value: Organization | null and onChange from the parent
  • Remove internal selected state entirely
  • Move the auto-select-single-org logic to callers (or a shared hook)
  • Update both callers (CreateUserForm, CreateTemplateForm) and all stories

This aligns the component with established codebase patterns and eliminates the remaining hybrid state complexity.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions