adobe / adobe/react-spectrum

Allow disabling drag or drop on a single gridlist item

Open
#5,704 5 comments 3 reactions 0 assignees View on GitHub
drag and drop enhancement needs investigation
Dominant language
TypeScript
Stars
15.9k
Forks
1.6k
Avg merge
3d 9m
Merged PRs (30d)
59

Description

### Provide a general summary of the feature here

As the title says, allow disabling drag or drop on a single gridlist item.

I saw the `disabledBehavior` property, but if I disable drag for an item I also disable selection, and I don't want that.

Another idea I had is to filter it out the item to deactivate in the `getItems` function that I pass to `useDragAndDrop`.
With this, although I get the dragEvent to have no content or data to drag, I can still drag the item.
In other words, `data-drop-target`, `react-aria-DropIndicator` and `renderDragPreview` still appear.

I know that in `renderDragPreview` I could return an empty div for example, but the mouse would still show that something is being dragged, and the drop-target/indicator still activates.

### 🤔 Expected Behavior?

Allow disabling drag or drop on a single gridlist item

### 😯 Current Behavior

It is not possible to disable drag or drop on a single gridlist item

### 💁 Possible Solution

_No response_

### 🔦 Context

a little context about my use case, because I think it may be helpful.

I'm trying to fake a Tree with a gridlist (turning the nesting level into an indent).

![image](https://github.com/adobe/react-spectrum/assets/43938777/46d079d0-aca9-46b6-8093-bd54e5e7dd28)

The Home element has some peculiarities:

❌ I don't want it to be draggable.
❌ I don't want to be able to drop "before" or "after" it (onReorder).
✅ I want it to be able to drop "inside" it (onItemDrop).

Note: this issue come from this discussion: https://github.com/adobe/react-spectrum/discussions/5697#discussioncomment-8146985

### 💻 Examples

_No response_

### 🧢 Your Company/Team

_No response_

### 🕷 Tracking Issue

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.