-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(dnd): pass keys and draggedKey as arguments to renderDropIndicator #8459
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
base: main
Are you sure you want to change the base?
Conversation
Build successful! 🎉 |
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.
If I keyboard drag, every drop indicator appears in the storybook example
@@ -181,6 +181,70 @@ ListBoxDnd.story = { | |||
} | |||
}; | |||
|
|||
export const ListBoxDndCustomDropIndicator = (props: ListBoxProps<typeof albums[0]>) => { |
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.
Can we make this story a little nicer, each image takes up so much of my screen that it's hard to use
it'd be really cool if we could use the image in the custom drop indicator as well, I feel like that'd be more true to life/the use case that was asked for. Wonder how hard it'd be to add the animations as well.
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.
Looks like the styles broke in #8272 and they're fine locally, just broken on the build. I'll try to improve the preview, just wanted to show that the keys and draggedKey were correct
Build successful! 🎉 |
## API Changes
react-aria-components/react-aria-components:DragAndDropOptions DragAndDropOptions {
acceptedDragTypes?: 'all' | Array<string | symbol> = 'all'
dropTargetDelegate?: DropTargetDelegate
getAllowedDropOperations?: () => Array<DropOperation>
getDropOperation?: (DropTarget, DragTypes, Array<DropOperation>) => DropOperation
getItems?: (Set<Key>) => 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
renderDragPreview?: (Array<DragItem>) => JSX.Element
- renderDropIndicator?: (DropTarget) => JSX.Element
+ renderDropIndicator?: (DropTarget, Set<Key>, Key) => JSX.Element
shouldAcceptItemDrop?: (ItemDropTarget, DragTypes) => boolean
} |
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.
Behavior looks good to me, just one small comment. Happy for it to go in as it is though
@@ -59,7 +59,7 @@ interface DropHooks { | |||
useDroppableCollection?: (props: DroppableCollectionOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DroppableCollectionResult, | |||
useDroppableItem?: (options: DroppableItemOptions, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DroppableItemResult, | |||
useDropIndicator?: (props: AriaDropIndicatorProps, state: DroppableCollectionState, ref: RefObject<HTMLElement | null>) => DropIndicatorAria, | |||
renderDropIndicator?: (target: DropTarget) => JSX.Element, | |||
renderDropIndicator?: (target: DropTarget, keys: Set<Key>, draggedKey?: Key) => JSX.Element, |
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 think the API is fine, its consistent with things like renderPreview
. One small nit would be to perhaps make keys
optional instead since we won't have access to keys/draggedKeys if the user is dropping from Finder for example
Closes #8410
Open to discussion on API/naming and if we want both of these.
✅ Pull Request Checklist:
📝 Test Instructions:
Try new story: https://reactspectrum.blob.core.windows.net/reactspectrum/e55eb5de291f8362ca0d011454cef157d9f36fa6/storybook/index.html?path=/story/react-aria-components--list-box-dnd-custom-drop-indicator&providerSwitcher-express=false
(not sure why the styles are broken in that story on the build, but they're also broken in the other listbox dnd story on main)
🧢 Your Project: