-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Discussion: drop decisions #1239
Comments
Hi @alexreardon, To conclude: I hope this helps. |
Having a There are also more cases were having conditional drop conditions would be helpful. |
+1 for having drop decisions for invalid positions. I've had a a few use cases where to keep list performance with windowing and grouped lists I've needed to create flattened lists to virtualize all items at a single level including header/footer. I've hacked together some drop logic that shifts index's to stick items above/below, but it would be nice to represent this directly during the drag where specific indexes/index-ranges wouldn't get the translated spacing downward. |
If you want to use E.g. if you have a limit restriction for export default function ElementList({
droppableId,
elementMap,
limit,
dragStart,
}) {
const [isDroppable, setIsDroppable] = useState(true);
const list = elementMap[droppableId];
useEffect(() => {
if (dragStart) {
const isSelf = dragStart.source.droppableId === droppableId;
const isLimitReached = list.length === limit;
if (isLimitReached && !isSelf) {
if (isDroppable) setIsDroppable(false);
}
} else {
if (!isDroppable) setIsDroppable(true);
}
}, [dragStart]);
const isDropDisabled = !isDroppable;
return (
<Droppable droppableId={droppableId} isDropDisabled={isDropDisabled}>
{provided => {
return (
<div
ref={provided.innerRef}
{...provided.droppableProps}
>
{provided.placeholder}
</div>
);
}}
</Droppable>
);
} This way you can add multiple restrictions, e.g. a whitelist to determine if the |
Right now we control what can be dropped over using
Droppable
type
andisDropEnabled
. A disabledDroppable
is not informed if it is being dragged over.Sometimes it is useful to know when a user is over a disabled droppable.
Option: change
isDropDisabled
behaviourUpdate the
onDragUpdate => DragUpdate
,Droppable => DroppableStateSnapshot
andDraggable => DraggableStateSnapshot
to includedisabled
Droppables
?Option: add
shouldDrop
callbackRather than relying on
isDragDisabled
a consumer could use a separate callbackshouldDrop
(or similar name) to decide whether a drop should be allowed after a user has indicated that a drop should end (such as my amouseup
event)Other?
My thinking on this is not super thorough. Other ideas would be appreciated!
The text was updated successfully, but these errors were encountered: