🚸 (editor) Improve block dragging behavior

This commit is contained in:
Baptiste Arnaud
2023-03-24 15:53:06 +01:00
parent e1de63a405
commit 92b92ed268
10 changed files with 56 additions and 46 deletions

View File

@@ -204,6 +204,7 @@ export const BlockNode = ({
onClick={handleClick}
data-testid={`block`}
w="full"
className="prevent-group-drag"
>
<HStack
flex="1"

View File

@@ -96,6 +96,7 @@ const NonMemoizedDraggableGroupNode = ({
handler: () => setIsFocused(false),
ref: groupRef,
capture: true,
isEnabled: isFocused,
})
// When the group is moved from external action (e.g. undo/redo), update the current coordinates
@@ -154,8 +155,13 @@ const NonMemoizedDraggableGroupNode = ({
useDrag(
({ first, last, offset: [offsetX, offsetY], event, target }) => {
event.stopPropagation()
if ((target as HTMLElement).classList.contains('prevent-group-drag'))
if (
(target as HTMLElement)
.closest('.prevent-group-drag')
?.classList.contains('prevent-group-drag')
)
return
if (first) {
setIsFocused(true)
setIsMouseDown(true)