Skip to content

feat: MUI 4 to BUI migration - replace Slider with BUI Slider #126

Description

@schultzp2020

Summary

Add a codemod that migrates MUI Slider to the BUI Slider API, including the min/max prop renames and the direct-value change handler model.

This issue is intentionally separate from the other choice controls because the slider value API and range behavior are distinct enough to warrant their own codemod boundary.

Detection Criteria

  • Slider imports from @material-ui/core/Slider
  • props such as min, max, step, value, defaultValue, and onChange
  • handler shapes that receive (_event, value) or similar MUI slider callbacks

Transformation Logic

  1. Replace the MUI import with Slider from @backstage/ui.
  2. Map min to minValue and max to maxValue.
  3. Preserve step, value, and defaultValue when the destination API supports them directly.
  4. Rewrite the common MUI callback shape from (_event, value) to the BUI direct-value callback when the local handler is trivial.
  5. Insert TODO(backstage-codemod): finish slider migration manually for range sliders, marks, value-label formatting, or custom event/value handling that is not obviously mechanical.

Before / After Example

Basic slider:

// Before
import Slider from '@material-ui/core/Slider';

<Slider min={0} max={100} value={value} onChange={(_e, next) => setValue(next as number)} />
// After
import { Slider } from '@backstage/ui';

<Slider minValue={0} maxValue={100} value={value} onChange={next => setValue(next as number)} />

Notes / Edge Cases

  • Do not guess how to migrate array/range slider values in the deterministic pass unless the destination API contract is explicit and tested.
  • Marks, labels, and custom formatting often carry UX intent; preserve or TODO them rather than dropping behavior silently.
  • This issue closes a remaining form-control gap in the migration skill inventory.

Changeset (when implementing)

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

Implementation notes

  • Target directory: codemods/misc/migrate-mui-slider-to-bui-slider/
  • Branch/worktree: .worktrees/feat/mui4-to-bui/migrate-mui-slider-to-bui-slider
  • 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