[TreeView] Add a method in the `apiRef` to toggle the editing status of an item
Summary
Ideally, the useTreeViewApiRef api should provide a command that receives the Id of an item to set editing status. I tried using the useTreeItem2Utils() api although its scope only encompass the tree view context. I'm looking to trigger the behavior in any react component.
Examples
By pressing the + button, the UI should display a new item in editing mode so the user can set the folder's name.
Motivation
I aim to implement a folder structure tree view by using the rich tree view component. Additionally, the user should be allowed to add or remove folders from the tree view.
Search keywords: RichTreeView
Hi,
Thanks for your contribution.
There is currently no method in the apiRef that allows to toggle the edition of an item. We could clean the setEditedItemId and add it to the apiRef.
If should probably add some safe-guards in the method to make sure we don't start editing an item that is not editable, the checks are currently done before calling it.
I'm adding the topic to our board :+1:
We can move setEditedItemId from the internal instance to the public API (look at how setItemSelection is defined for reference).
Before making it public, we need to make sure it does not update the state if the item is not editable (and remove the check in toggleItemEditing in the useTreeItemUtils hook).
And we should rename it to setEditedItem.
We should also add a doc example here The use case described in this issue would be a good candidate for the doc example.
We also need 1-2 tests.
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.