Skip to content

feat: MUI 4 to BUI migration - replace Select wrapper patterns with BUI Select #122

Description

@schultzp2020

Summary

Add a codemod that migrates the common MUI FormControl + InputLabel + Select + MenuItem pattern to the BUI Select API.

This is a structural form migration rather than a simple import swap. The codemod should target the straightforward single-select cases first and use TODO markers for more semantic variants such as grouped or multi-select options.

Detection Criteria

  • FormControl, InputLabel, Select, MenuItem, and optional FormHelperText imports from @material-ui/core
  • inline MenuItem children with static value props and text labels
  • select onChange handlers that read event.target.value

Transformation Logic

  1. Replace the MUI wrapper imports with Select from @backstage/ui when the pattern is the standard single-select shape.
  2. Collapse the wrapper structure into a single Select element with label, selectedKey, and onSelectionChange.
  3. Convert inline MenuItem children into a BUI options array with id and label keys when each option is statically visible.
  4. Rewrite the common onChange={e => setValue(e.target.value as string)} shape to onSelectionChange={key => setValue(key as string)}.
  5. Leave TODO(backstage-codemod): finish Select migration manually when the source uses multiple, grouped options, helper text, or nontrivial option rendering.

Before / After Example

Basic single select:

// Before
<FormControl fullWidth>
  <InputLabel>Framework</InputLabel>
  <Select value={value} onChange={e => setValue(e.target.value as string)}>
    <MenuItem value="react">React</MenuItem>
    <MenuItem value="angular">Angular</MenuItem>
  </Select>
</FormControl>
// After
<Select
  label="Framework"
  selectedKey={value}
  onSelectionChange={key => setValue(key as string)}
  options={[
    { id: 'react', label: 'React' },
    { id: 'angular', label: 'Angular' },
  ]}
/>

Notes / Edge Cases

  • This issue should stay separate from the @backstage/ui v1.52 Select/Combobox deprecation codemod; the source components and destination APIs are different.
  • Do not try to preserve arbitrary MenuItem children markup in the deterministic pass.
  • If helper text or validation UI matters to the migrated form, leave a TODO marker rather than dropping it silently.
  • The migration skill treats Select as a first-class MUI to BUI family even though representative PR evidence is thinner than for alerts or buttons.

Changeset (when implementing)

  • Package: @backstage/migrate-mui-select-family-to-bui-select
  • Bump: minor (initial release)
  • Summary example: Add codemod to migrate mui select family to bui select for the Backstage MUI 4 to BUI migration

Implementation notes

  • Target directory: codemods/misc/migrate-mui-select-family-to-bui-select/
  • Branch/worktree: .worktrees/feat/mui4-to-bui/migrate-mui-select-family-to-bui-select
  • Open PR when ready; one PR per codemod

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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