Open KaralyosBela opened 2 days ago
This is because the custom label does not change between editing state and normal state. For this to work you need to get the itemState like this: https://github.com/mui/mui-x/blob/b907bb5ae388b8e975c838f4ad188bfacefe9f94/packages/x-tree-view/src/TreeItem/TreeItemContent.tsx#L90-L106
And then render an input based on the editable
property. Like this: https://github.com/mui/mui-x/blob/b907bb5ae388b8e975c838f4ad188bfacefe9f94/packages/x-tree-view/src/TreeItem/TreeItemContent.tsx#L174-L180
[!WARNING] The label editing feature is still experimental. Any future release might include breaking changes.
Thanks! It works with this solution! :) Another question regarding label edit: if this option is enabled, is there any way to collapse/extend the tree menu item on clicking anywhere other than the collapse/extend icon? Or is this limited with this feature?
I guess this might be possible, but only with a high level of customization.
One idea would be to disable the double click on the custom label element and only allow entering the editing state by pressing ENTER
@flaviendelangle can we support something like this?
is there any way to collapse/extend the tree menu item on clicking anywhere other than the collapse/extend icon? Or is this limited with this feature?
You can choose what is triggering the expand/collapse with the expansionTrigger
prop.
It would not work well with the default editing behavior, but you can try to customize yours to have something that works correctly (probably with an icon to start the editing).
Thanks guys!
The problem in depth
I'm having trouble getting the labelEditing experimental feature to work with a custom TreeItem when using RichTreeViewPro. According to the MUI documentation, there's an example of using a custom TreeItem with the RichTreeViewPro component here. However, when I add the experimentalFeatures={{ labelEditing: true }} and the isItemEditable part, it doesn't seem to function as expected.
Am I missing something, or is there an additional step I need to take to make this work?
Your environment
Chrome "@mui/base": "^5.0.0-beta.26", "@mui/icons-material": "^5.14.19", "@mui/lab": "5.0.0-alpha.141", "@mui/material": "^5.15.14", "@mui/styles": "^5.14.20", "@mui/x-data-grid-premium": "^7.15.0", "@mui/x-license": "^7.0.0", "@mui/x-tree-view": "^7.2.0", "@mui/x-tree-view-pro": "^7.16.0",
`npx @mui/envinfo`
``` Don't forget to mention which browser you used. Output from `npx @mui/envinfo` goes here. ```Search keywords: rich tree view, label renaming, custom tree item Order ID: 86461