Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TreeView] Replace <TreeItem /> with <TreeItem2 /> and migrate all the components and utils #14913

Merged
merged 30 commits into from
Oct 23, 2024

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Oct 10, 2024

Closes #14767

  • Remove TreeItem
  • Rename TreeItem2 => TreeItem (same for all other components and utils with TreeItem2 in their name)
  • Update doc
  • Simplify the test setup
  • Write codemod
  • Write migration guide
  • Write changelog highlight (waiting for the migration guide to be review)

Changelog

Tree View

  • The ContentComponent or ContentProps props of the <TreeItem /> component have been removed in favor of the new slots, slotProps props and of the useTreeItem hook.

    Learn more about the anatomy of the Tree Items and the customization utilities provided on the Tree Item Customization page.

  • The onClick and onMouseDown were the only event callback that were passed to the content of the Tree Item instead of its root.
    The goal was to make sure that the callback was not fired when clicking on a descendant of a giving item.
    This inconsistency has been solved, all the event manager now target the root of the item, and you can use the onItemClick prop on the Tree View component to target the content of an item:

    -<SimpleTreeView>
    +<SimpleTreeView onItemClick={handleItemClick}>
    -  <TreeItem onClick={handleItemClick}>
    +  <TreeItem >
     </SimpleTreeView>
  • All the new Tree Item-related components and utils (introduced in the previous major to improve the DX of the Tree Item component) are becoming the default way of using the Tree Item and are therefore losing their 2 suffix:

     import * as React from 'react';
     import {
    -  TreeItem2,
    +  TreeItem,
    -  TreeItem2Root,
    +  TreeItemRoot,
    -  TreeItem2Content,
    +  TreeItemContent,
    -  TreeItem2IconContainer,
    +  TreeItemIconContainer,
    -  TreeItem2GroupTransition,
    +  TreeItemGroupTransition,
    -  TreeItem2Checkbox,
    +  TreeItemCheckbox,
    -  TreeItem2Label,
    +  TreeItemLabel,
    -  TreeItem2Props,
    +  TreeItemProps,
    -  TreeItem2Slots,
    +  TreeItemSlots,
    -  TreeItem2SlotProps,
    +  TreeItemSlotProps,
    - } from '@mui/x-tree-view/TreeItem2';
    + } from '@mui/x-tree-view/TreeItem';
     import {
    -  useTreeItem2,
    +  useTreeItem,
    -  unstable_useTreeItem2 as useAliasedTreeItem,
    +  unstable_useTreeItem as useAliasedTreeItem,
    -  UseTreeItem2Parameters,
    +  UseTreeItemParameters,
    -  UseTreeItem2ReturnValue,
    +  UseTreeItemReturnValue,
    -  UseTreeItem2Status,
    +  UseTreeItemStatus,
    -  UseTreeItem2RootSlotOwnProps,
    +  UseTreeItemRootSlotOwnProps,
    -  UseTreeItem2ContentSlotOwnProps,
    +  UseTreeItemContentSlotOwnProps,
    -  UseTreeItem2LabelInputSlotOwnProps,
    +  UseTreeItemLabelInputSlotOwnProps,
    -  UseTreeItem2LabelSlotOwnProps,
    +  UseTreeItemLabelSlotOwnProps,
    -  UseTreeItem2CheckboxSlotOwnProps,
    +  UseTreeItemCheckboxSlotOwnProps,
    -  UseTreeItem2IconContainerSlotOwnProps,
    +  UseTreeItemIconContainerSlotOwnProps,
    -  UseTreeItem2GroupTransitionSlotOwnProps,
    +  UseTreeItemGroupTransitionSlotOwnProps,
    -  UseTreeItem2DragAndDropOverlaySlotOwnProps,
    +  UseTreeItemDragAndDropOverlaySlotOwnProps,
    - } from '@mui/x-tree-view/useTreeItem2';
    + } from '@mui/x-tree-view/useTreeItem';
    - import { useTreeItem2Utils } from '@mui/x-tree-view/hooks';
    + import { useTreeItemUtils } from '@mui/x-tree-view/hooks';
     import {
    -  TreeItem2Provider,
    +  TreeItemProvider,
    -  TreeItem2ProviderProps,
    +  TreeItemProviderProps,
    - } from '@mui/x-tree-view/TreeItem2Provider';
    + } from '@mui/x-tree-view/TreeItemProvider';
     import {
    -  TreeItem2Icon,
    +  TreeItemIcon,
    -  TreeItem2IconProps,
    +  TreeItemIconProps,
    -  TreeItem2IconSlots,
    +  TreeItemIconSlots,
    -  TreeItem2IconSlotProps,
    +  TreeItemIconSlotProps,
    - } from '@mui/x-tree-view/TreeItem2Icon';
    + } from '@mui/x-tree-view/TreeItemIcon';
     import {
    -  TreeItem2DragAndDropOverlay,
    +  TreeItemDragAndDropOverlay,
    -  TreeItem2DragAndDropOverlayProps,
    +  TreeItemDragAndDropOverlayProps,
    - } from '@mui/x-tree-view/TreeItem2DragAndDropOverlay';
    + } from '@mui/x-tree-view/TreeItemDragAndDropOverlay';
     import {
    -  TreeItem2LabelInput,
    +  TreeItemLabelInput,
    -  TreeItem2LabelInputProps,
    +  TreeItemLabelInputProps,
    - } from '@mui/x-tree-view/TreeItem2LabelInput';
    + } from '@mui/x-tree-view/TreeItemLabelInput';

@flaviendelangle flaviendelangle self-assigned this Oct 10, 2024
@flaviendelangle flaviendelangle added breaking change component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! labels Oct 10, 2024
@flaviendelangle flaviendelangle marked this pull request as ready for review October 11, 2024 15:17
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 16, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 16, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 16, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 21, 2024
@flaviendelangle flaviendelangle changed the title [TreeView] Replace TreeItem with TreeItem2 and migrate all the components and utils [TreeView] Replace <TreeItem /> with <TreeItem2 /> and migrate all the components and utils Oct 22, 2024
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 22, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 22, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 22, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 23, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 23, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 23, 2024
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 23, 2024
Copy link
Contributor

@noraleonte noraleonte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the effort 💙 🚀

packages/x-codemod/README.md Outdated Show resolved Hide resolved
@@ -19,7 +19,7 @@ Hover over them in the demo below to see each slot.
<!-- TBD which option is the best: interactive or image -->
<!-- {{"demo": "CustomTreeItemDemo.js", "hideToolbar": true}} -->

{{"component": "modules/components/TreeItem2Anatomy.js"}}
{{"component": "modules/components/TreeItemAnatomy.js"}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The labels on the image still have the old naming. I'm creating a follow-up to replace them 😄

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 23, 2024
@flaviendelangle flaviendelangle merged commit bcbc3d1 into mui:master Oct 23, 2024
18 checks passed
@flaviendelangle flaviendelangle deleted the tree-item-2 branch October 23, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: tree view TreeView, TreeItem. This is the name of the generic UI component, not the React module! v8.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TreeView] Drop TreeItem and rename TreeItem2 into TreeItem (same for useTreeItem2 and all related components)
4 participants