Skip to content

Commit

Permalink
[TreeView] Always apply the indentation at the item level instead of …
Browse files Browse the repository at this point in the history
…the group level
  • Loading branch information
flaviendelangle committed Oct 24, 2024
1 parent 103c59c commit a0bac72
Show file tree
Hide file tree
Showing 39 changed files with 34 additions and 245 deletions.
1 change: 0 additions & 1 deletion docs/data/tree-view/rich-tree-view/ordering/DragAndDrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default function DragAndDrop() {
itemsReordering
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default function DragAndDrop() {
itemsReordering
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
itemsReordering
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export default function FileExplorer() {
defaultExpandedItems={['1', '1.1']}
sx={{ height: 'fit-content', flexGrow: 1, maxWidth: 400, overflowY: 'auto' }}
slots={{ item: CustomTreeItem }}
experimentalFeatures={{ indentationAtItemLevel: true, itemsReordering: true }}
experimentalFeatures={{ itemsReordering: true }}
itemsReordering
canMoveItemToNewPosition={(params) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export default function FileExplorer() {
defaultExpandedItems={['1', '1.1']}
sx={{ height: 'fit-content', flexGrow: 1, maxWidth: 400, overflowY: 'auto' }}
slots={{ item: CustomTreeItem }}
experimentalFeatures={{ indentationAtItemLevel: true, itemsReordering: true }}
experimentalFeatures={{ itemsReordering: true }}
itemsReordering
canMoveItemToNewPosition={(params) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export default function OnItemPositionChange() {
items={MUI_X_PRODUCTS}
itemsReordering
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
defaultExpandedItems={['grid', 'pickers']}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export default function OnItemPositionChange() {
items={MUI_X_PRODUCTS}
itemsReordering
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
defaultExpandedItems={['grid', 'pickers']}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export default function OnlyReorderFromDragHandle() {
items={MUI_X_PRODUCTS}
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
itemsReordering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export default function OnlyReorderFromDragHandle() {
items={MUI_X_PRODUCTS}
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
itemsReordering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
items={MUI_X_PRODUCTS}
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
itemsReordering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default function OnlyReorderInSameParent() {
itemsReordering
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
canMoveItemToNewPosition={(params) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default function OnlyReorderInSameParent() {
itemsReordering
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
canMoveItemToNewPosition={(params) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
itemsReordering
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
canMoveItemToNewPosition={(params) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default function OnlyReorderLeaves() {
itemsReordering
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
apiRef={apiRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export default function OnlyReorderLeaves() {
itemsReordering
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
apiRef={apiRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
itemsReordering
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
apiRef={apiRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export default function SendAllItemsToServer() {
itemsReordering
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
onItemPositionChange={handleItemPositionChangeTreeViewA}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export default function SendAllItemsToServer() {
itemsReordering
defaultExpandedItems={['grid', 'pickers']}
experimentalFeatures={{
indentationAtItemLevel: true,
itemsReordering: true,
}}
onItemPositionChange={handleItemPositionChangeTreeViewA}
Expand Down
7 changes: 2 additions & 5 deletions docs/data/tree-view/rich-tree-view/ordering/ordering.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/treeview/
<p class="description">Drag and drop your items to reorder them.</p>

:::success
To be able to reorder items, you first have to enable the `indentationAtItemLevel` and the `itemsReordering` experimental features:
To be able to reorder items, you first have to enable the `itemsReordering` experimental feature:

```tsx
<RichTreeViewPro
items={ITEMS}
experimentalFeatures={{ indentationAtItemLevel: true, itemsReordering: true }}
/>
<RichTreeViewPro items={ITEMS} experimentalFeatures={{ itemsReordering: true }} />
```

See [Tree Item Customization—Apply the nested item's indentation at the item level](/x/react-tree-view/tree-item-customization/#apply-the-nested-items-indentation-at-the-item-level) for more details.
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -82,40 +82,6 @@ By default, a nested item is indented by `12px` from its parent item.

{{"demo": "ItemChildrenIndentationProp.js"}}

:::success
If you are using a custom Tree Item component, and you want to override the padding,
then apply the following padding to your `groupTransition` element:

```ts
const CustomTreeItemGroupTransition = styled(TreeItemGroupTransition)(({ theme }) => ({
// ...other styles
paddingLeft: `var(--TreeView-itemChildrenIndentation)`,
}
```
If you are using the `indentationAtItemLevel` prop, then instead apply the following padding to your `content` element:
```ts
const CustomTreeItemContent = styled(TreeItemContent)(({ theme }) => ({
// ...other styles
paddingLeft:
`calc(${theme.spacing(1)} + var(--TreeView-itemChildrenIndentation) * var(--TreeView-itemDepth))`,
}
```
:::
### Apply the nested item's indentation at the item level
By default, the indentation of nested items is applied by the `groupTransition` slot of its parent (i.e.: the DOM element that wraps all the children of a given item).
This approach is not compatible with upcoming features like the reordering of items using drag & drop.
To apply the indentation at the item level (i.e.: have each item responsible for setting its own indentation using the `padding-left` CSS property on its `content` slot),
you can use the `indentationAtItemLevel` experimental feature.
It will become the default behavior in the next major version of the Tree View component.
{{"demo": "IndentationAtItemLevel.js"}}
:::success
If you are using a custom Tree Item component, and you want to override the padding,
then apply the following padding to your `content` element:
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/tree-view/rich-tree-view-pro.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@
"default": "'content'"
},
"experimentalFeatures": {
"type": {
"name": "shape",
"description": "{ indentationAtItemLevel?: bool, itemsReordering?: bool, labelEditing?: bool }"
}
"type": { "name": "shape", "description": "{ itemsReordering?: bool, labelEditing?: bool }" }
},
"getItemId": {
"type": { "name": "func" },
Expand Down
5 changes: 1 addition & 4 deletions docs/pages/x/api/tree-view/rich-tree-view.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
"default": "'content'"
},
"experimentalFeatures": {
"type": {
"name": "shape",
"description": "{ indentationAtItemLevel?: bool, labelEditing?: bool }"
}
"type": { "name": "shape", "description": "{ labelEditing?: bool }" }
},
"getItemId": {
"type": { "name": "func" },
Expand Down
4 changes: 1 addition & 3 deletions docs/pages/x/api/tree-view/simple-tree-view.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
"type": { "name": "enum", "description": "'content'<br>&#124;&nbsp;'iconContainer'" },
"default": "'content'"
},
"experimentalFeatures": {
"type": { "name": "shape", "description": "{ indentationAtItemLevel?: bool }" }
},
"experimentalFeatures": { "type": { "name": "object" } },
"id": { "type": { "name": "string" } },
"itemChildrenIndentation": {
"type": { "name": "union", "description": "number<br>&#124;&nbsp;string" },
Expand Down
4 changes: 1 addition & 3 deletions docs/pages/x/api/tree-view/tree-view.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
"type": { "name": "enum", "description": "'content'<br>&#124;&nbsp;'iconContainer'" },
"default": "'content'"
},
"experimentalFeatures": {
"type": { "name": "shape", "description": "{ indentationAtItemLevel?: bool }" }
},
"experimentalFeatures": { "type": { "name": "object" } },
"id": { "type": { "name": "string" } },
"itemChildrenIndentation": {
"type": { "name": "union", "description": "number<br>&#124;&nbsp;string" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ RichTreeViewPro.propTypes = {
* the feature will be fully disabled and any property / method call will not have any effect.
*/
experimentalFeatures: PropTypes.shape({
indentationAtItemLevel: PropTypes.bool,
itemsReordering: PropTypes.bool,
labelEditing: PropTypes.bool,
}),
Expand Down
Loading

0 comments on commit a0bac72

Please sign in to comment.