Skip to content

feat: MUI 4 to BUI migration - replace Tooltip with TooltipTrigger #116

Description

@schultzp2020

Summary

Add a codemod that replaces MUI Tooltip usage with the BUI TooltipTrigger + Tooltip pattern for the common single-child wrapper cases.

The codemod should stay deterministic: rewrite the straightforward wrapper structure and leave TODO markers for controlled or unusually nested tooltip implementations.

Detection Criteria

  • Tooltip imports from @material-ui/core/Tooltip
  • title, placement, open, onClose, and leaveDelay props on those tooltips
  • a single JSX child wrapped by the tooltip

Transformation Logic

  1. Replace the MUI import with TooltipTrigger and Tooltip from @backstage/ui.
  2. Rewrite the simple wrapper shape so the original tooltip child becomes the first child of TooltipTrigger and the tooltip content becomes the BUI Tooltip child.
  3. Move the MUI title content into the BUI Tooltip body.
  4. Preserve simple controlled-open patterns only when they can be mapped mechanically to isOpen / onOpenChange on TooltipTrigger.
  5. If the wrapper structure is not a single local child or the open-state logic is nontrivial, leave TODO(backstage-codemod): finish tooltip migration manually.

Before / After Example

Simple tooltip wrapper:

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

<Tooltip title="More actions">
  <IconButton aria-label="more">
    <MoreVertIcon />
  </IconButton>
</Tooltip>
// After
import { Tooltip, TooltipTrigger } from '@backstage/ui';

<TooltipTrigger>
  <IconButton aria-label="more">
    <MoreVertIcon />
  </IconButton>
  <Tooltip>More actions</Tooltip>
</TooltipTrigger>

Notes / Edge Cases

  • Placement-only props can be preserved only if the BUI tooltip supports the same value directly; otherwise leave a TODO marker.
  • Tooltip migration should commute with both the IconButton and icon-source codemods.
  • Do not try to auto-wrap multiple children or fragments in synthetic spans without a clear prior-art rule.
  • Representative Backstage migrations include CopyTextButton and notification actions.

Changeset (when implementing)

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

Implementation notes

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