-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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] Fix drag and drop issue with label editing #15636
base: master
Are you sure you want to change the base?
Conversation
Deploy preview: https://deploy-preview-15636--material-ui-x.netlify.app/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll check the behavior later 🙏
@@ -7,6 +7,7 @@ import { | |||
isTargetInDescendants, | |||
useSelector, | |||
} from '@mui/x-tree-view/internals'; | |||
import { selectorIsItemBeingEdited } from '@mui/x-tree-view/internals/plugins/useTreeViewLabel/useTreeViewLabel.selectors'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one has to be exported from internals/index.ts
@@ -34,6 +36,9 @@ export const useTreeViewItemsReorderingItemPlugin: TreeViewItemPlugin = ({ props | |||
itemId, | |||
); | |||
const isValidTarget = useSelector(store, selectorItemsReorderingIsValidTarget, itemId); | |||
const draggedItemId = useSelector(store, selectorDraggedItem); | |||
|
|||
const isBeingEdited = useSelector(store, selectorIsItemBeingEdited, draggedItemId as string); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isBeingEdited = useSelector(store, selectorIsItemBeingEdited, draggedItemId as string); | |
If `draggedItemId` can be null, you can do: | |
const isBeingEdited = useSelector( | |
store, | |
state => draggedItemId == nul ? false : selectorIsItemBeingEdited(draggedItemId), | |
); |
Or you can update selectorIsItemBeingEdited
to support null
, which would make sense to me as well.
/** | ||
* Get the id of the item that is currently being dragged. | ||
* @param {TreeViewState<[UseTreeViewItemsReorderingSignature]>} state The state of the tree view. | ||
* @returns {string} The id of the currently dragged item. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be missing null
*/ | ||
export const selectorDraggedItem = createSelector( | ||
[selectorItemsReordering], | ||
(itemsReordering) => itemsReordering && itemsReordering.draggedItemId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(itemsReordering) => itemsReordering && itemsReordering.draggedItemId, | |
(itemsReordering) => itemsReordering?.draggedItemId |
closes #15533