WIP: feat(dnd) customize pointer drag source#9745
Open
reidbarber wants to merge 3 commits intomainfrom
Open
Conversation
|
Build successful! 🎉 |
## API Changes
react-aria-components/react-aria-components:GridListRenderProps GridListRenderProps {
isDropTarget: boolean
isEmpty: boolean
isFocusVisible: boolean
isFocused: boolean
layout: 'stack' | 'grid'
+ pointerDragSource?: 'item' | 'dragButton'
state: ListState<unknown>
}/react-aria-components:TableRenderProps TableRenderProps {
isDropTarget: boolean
isFocusVisible: boolean
isFocused: boolean
+ pointerDragSource?: 'item' | 'dragButton'
state: TableState<unknown>
}/react-aria-components:TreeRenderProps TreeRenderProps {
allowsDragging: boolean
isEmpty: boolean
isFocusVisible: boolean
isFocused: boolean
+ pointerDragSource?: 'item' | 'dragButton'
selectionMode: SelectionMode
state: TreeState<unknown>
}/react-aria-components:DragOptions DragOptions {
getAllowedDropOperations?: () => Array<DropOperation>
getItems: () => Array<DragItem>
hasDragButton?: boolean
isDisabled?: boolean
onDragEnd?: (DragEndEvent) => void
onDragMove?: (DragMoveEvent) => void
onDragStart?: (DragStartEvent) => void
+ pointerDragSource?: 'item' | 'dragButton'
preview?: RefObject<DragPreviewRenderer | null>
}/react-aria-components:DragAndDropOptions DragAndDropOptions <T = {}> {
acceptedDragTypes?: 'all' | Array<string | symbol> = 'all'
dropTargetDelegate?: DropTargetDelegate
getAllowedDropOperations?: () => Array<DropOperation>
getDropOperation?: (DropTarget, DragTypes, Array<DropOperation>) => DropOperation
getItems?: (Set<Key>, Array<T>) => Array<DragItem> = () => []
isDisabled?: boolean
onDragEnd?: (DraggableCollectionEndEvent) => void
onDragMove?: (DraggableCollectionMoveEvent) => void
onDragStart?: (DraggableCollectionStartEvent) => void
onDrop?: (DroppableCollectionDropEvent) => void
onDropActivate?: (DroppableCollectionActivateEvent) => void
onDropEnter?: (DroppableCollectionEnterEvent) => void
onDropExit?: (DroppableCollectionExitEvent) => void
onInsert?: (DroppableCollectionInsertDropEvent) => void
onItemDrop?: (DroppableCollectionOnItemDropEvent) => void
onMove?: (DroppableCollectionReorderEvent) => void
onReorder?: (DroppableCollectionReorderEvent) => void
onRootDrop?: (DroppableCollectionRootDropEvent) => void
+ pointerDragSource?: 'item' | 'dragButton' = "item"
renderDragPreview?: (Array<DragItem>) => JSX.Element | {
element: JSX.Element
x: number
y: number
renderDropIndicator?: (DropTarget) => JSX.Element
shouldAcceptItemDrop?: (ItemDropTarget, DragTypes) => boolean
}@react-aria/dnd/@react-aria/dnd:DraggableItemProps DraggableItemProps {
hasAction?: boolean
hasDragButton?: boolean
key: Key
+ pointerDragSource?: 'item' | 'dragButton'
}/@react-aria/dnd:DragOptions DragOptions {
getAllowedDropOperations?: () => Array<DropOperation>
getItems: () => Array<DragItem>
hasDragButton?: boolean
isDisabled?: boolean
onDragEnd?: (DragEndEvent) => void
onDragMove?: (DragMoveEvent) => void
onDragStart?: (DragStartEvent) => void
+ pointerDragSource?: 'item' | 'dragButton'
preview?: RefObject<DragPreviewRenderer | null>
} |
Contributor
|
@reidbarber Since this is about dnd, there is a bug i just stumbled upon, where when you lift your pointer fast enough, there is no release event being registered so the drag preview stays open indefinitely until the next render. Its reproducible with a trackpad on OSX in the deployed storybook on main (tree dnd story). Just wanted to share in case you want to squash that here too 👍 |
Member
Author
|
@nwidynski Thanks! I hadn't seen that yet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #9739
Note: This is a PoC at this point, and needs more discussion before committing.
Adds a
pointerDragSource?: 'item' | 'dragButton'option that allows the user to indicate that pointer drags must originate from the drag button (if it exists).Open questions:
Remaining work:
✅ Pull Request Checklist:
📝 Test Instructions:
Test it with useDrag.
Test it with Table.
🧢 Your Project: