Skip to content

Commit f7aa828

Browse files
authored
Move React Aria dnd introduction to concepts section (#5088)
1 parent 6a5394b commit f7aa828

File tree

5 files changed

+125
-6
lines changed

5 files changed

+125
-6
lines changed

packages/@react-aria/dnd/docs/dnd.mdx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ import {Layout} from '@react-spectrum/docs';
1919
export default Layout;
2020

2121
---
22-
category: Drag and Drop
22+
category: Concepts
2323
keywords: [drag, drop, dnd, drag and drop, aria, accessibility]
24-
navigationTitle: Introduction
25-
type: interaction
24+
order: 10
2625
---
2726

2827
# Drag and Drop
@@ -59,7 +58,7 @@ Many operating systems display drop operations in the form of a cursor change wh
5958
<figcaption id="drop-operation-caption" style={{fontStyle: 'italic'}}>Visual feedback for a copy drop operation.</figcaption>
6059
</figure>
6160

62-
Collection components built with hooks such as [useListBox](useListBox.html), [useTable](useTable.html), and [useGridList](useGridList.html), support multiple **drop positions**. The collection may support a `"root"` drop position, allowing items to be dropped on the collection as a whole. It may also support `"on"` drop positions, such as when dropping into a folder in a list. If the collection allows the user to control the order of the items, it may also support `"between"` drop positions, allowing the user to insert or move items between other items. This is indicated by rendering a **drop indicator** between two items when the user drags over the space between them. Any number of these drop positions can be allowed at the same time and the component can use the types of the dragged items to selectively allow or disallow certain positions.
61+
Collection components such as [ListBox](ListBox.html), [Table](Table.html), and [GridList](GridList.html) support multiple **drop positions**. The collection may support a `"root"` drop position, allowing items to be dropped on the collection as a whole. It may also support `"on"` drop positions, such as when dropping into a folder in a list. If the collection allows the user to control the order of the items, it may also support `"between"` drop positions, allowing the user to insert or move items between other items. This is indicated by rendering a **drop indicator** between two items when the user drags over the space between them. Any number of these drop positions can be allowed at the same time and the component can use the types of the dragged items to selectively allow or disallow certain positions.
6362

6463
<figure style={{display: 'flex', flexDirection: 'column', alignItems: 'center', margin: '20px 0'}}>
6564
<div style={{display: 'flex', flexWrap: 'wrap', justifyContent: 'center', gap: 50, marginBottom: 4, background: 'var(--anatomy-gray-100)', padding: 32, width: 'calc(100% - 64px)', borderRadius: 4}}>
@@ -74,9 +73,9 @@ Collection components built with hooks such as [useListBox](useListBox.html), [u
7473

7574
While drag and drop has historically been mostly limited to mouse and touchscreen users, keyboard and screen reader friendly alternatives are important for users who cannot use these interaction methods. For example, copy and paste can often be used as an alternative to drag and drop to allow the user to move an object from one location to another. However, copy and paste does not cover all of the possible interactions that drag and drop allows. For example, it is hard to specify an exact location to insert an item into a list on paste, or even know where pasting is accepted. Users must either already know where they can paste, or navigate aimlessly until they find a valid location.
7675

77-
React Aria implements keyboard and screen reader friendly interactions for drag and drop that provide full parity with the mouse and touch experiences. Users can press <Keyboard>Enter</Keyboard> on a draggable element to enter drag and drop mode. Then, they can press <Keyboard>Tab</Keyboard> to cycle between the drop targets that accept the dragged data, then press <Keyboard>Enter</Keyboard> to drop. <Keyboard>Escape</Keyboard> can be pressed at any time to cancel. Touch screen reader users can also drag by double tapping to activate drag and drop mode, swiping between drop targets, and double tapping again to drop. Screen reader announcements are included to help guide the user through this process. All of this is built into the [useDrag](useDrag.html) and [useDrop](useDrop.html) hooks.
76+
React Aria implements keyboard and screen reader friendly interactions for drag and drop that provide full parity with the mouse and touch experiences. Users can press <Keyboard>Enter</Keyboard> on a draggable element to enter drag and drop mode. Then, they can press <Keyboard>Tab</Keyboard> to cycle between the drop targets that accept the dragged data, then press <Keyboard>Enter</Keyboard> to drop. <Keyboard>Escape</Keyboard> can be pressed at any time to cancel. Touch screen reader users can also drag by double tapping to activate drag and drop mode, swiping between drop targets, and double tapping again to drop. Screen reader announcements are included to help guide the user through this process. All of this is built into the [useDrag](useDrag.html) and [useDrop](useDrop.html) hooks, and components such as [DropZone](DropZone.html).
7877

79-
Collection components such as lists or tables are treated as a single drop target, so that users can easily tab past them to get to the next drop target without going through every item. Instead, within a droppable collection, keys such as <Keyboard>ArrowDown</Keyboard> and <Keyboard>ArrowUp</Keyboard> can be used to select a drop position, such as on an item, or between items. The exact interactions may vary depending on the layout of the collection component. Drag and drop for collections is implemented by the [useDraggableCollection](useDraggableCollection.html) and [useDroppableCollection](useDroppableCollection.html) hooks.
78+
Collection components such as lists or tables are treated as a single drop target, so that users can easily tab past them to get to the next drop target without going through every item. Instead, within a droppable collection, keys such as <Keyboard>ArrowDown</Keyboard> and <Keyboard>ArrowUp</Keyboard> can be used to select a drop position, such as on an item, or between items. The exact interactions may vary depending on the layout of the collection component. Drag and drop for collections is implemented by the [useDraggableCollection](useDraggableCollection.html) and [useDroppableCollection](useDroppableCollection.html) hooks, which are built into in the [ListBox](ListBox.html), [Table](Table.html), and [GridList](GridList.html) components.
8079

8180
Draggable elements can sometimes have other interactions that conflict with the keyboard and screen reader interactions needed to initiate a drag, such as the <Keyboard>Enter</Keyboard> key. In these cases, an explicit **drag affordance** may be added. Keyboard and screen reader users can focus this element, and use it to initiate drag and drop for the parent item. In addition, this has the added benefit of making drag and drop more discoverable.
8281

Lines changed: 96 additions & 0 deletions
Loading

packages/react-aria-components/docs/GridList.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {ExampleCard} from '@react-spectrum/docs/src/ExampleCard';
2222
import {Keyboard} from '@react-spectrum/text';
2323
import Collections from '@react-spectrum/docs/pages/assets/component-illustrations/Collections.svg';
2424
import Selection from '@react-spectrum/docs/pages/assets/component-illustrations/Selection.svg';
25+
import DragAndDrop from '@react-spectrum/docs/pages/assets/component-illustrations/DragAndDrop.svg';
2526
import Checkbox from '@react-spectrum/docs/pages/assets/component-illustrations/Checkbox.svg';
2627
import Button from '@react-spectrum/docs/pages/assets/component-illustrations/Button.svg';
2728

@@ -361,6 +362,13 @@ import {GridList, Item, Checkbox, Button} from 'react-aria-components';
361362
<Selection />
362363
</ExampleCard>
363364

365+
<ExampleCard
366+
url="dnd.html"
367+
title="Drag and drop"
368+
description="Concepts and interactions for an accessible drag and drop experience.">
369+
<DragAndDrop />
370+
</ExampleCard>
371+
364372
</section>
365373

366374
### Composed components

packages/react-aria-components/docs/ListBox.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {ExampleCard} from '@react-spectrum/docs/src/ExampleCard';
2222
import {Keyboard} from '@react-spectrum/text';
2323
import Collections from '@react-spectrum/docs/pages/assets/component-illustrations/Collections.svg';
2424
import Selection from '@react-spectrum/docs/pages/assets/component-illustrations/Selection.svg';
25+
import DragAndDrop from '@react-spectrum/docs/pages/assets/component-illustrations/DragAndDrop.svg';
2526

2627
---
2728
category: Collections
@@ -217,6 +218,13 @@ import {ListBox, Item, Section, Header, Text} from 'react-aria-components';
217218
<Selection />
218219
</ExampleCard>
219220

221+
<ExampleCard
222+
url="dnd.html"
223+
title="Drag and drop"
224+
description="Concepts and interactions for an accessible drag and drop experience.">
225+
<DragAndDrop />
226+
</ExampleCard>
227+
220228
</section>
221229

222230
## Reusable wrappers

packages/react-aria-components/docs/Table.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {ExampleCard} from '@react-spectrum/docs/src/ExampleCard';
2222
import {Keyboard} from '@react-spectrum/text';
2323
import Collections from '@react-spectrum/docs/pages/assets/component-illustrations/Collections.svg';
2424
import Selection from '@react-spectrum/docs/pages/assets/component-illustrations/Selection.svg';
25+
import DragAndDrop from '@react-spectrum/docs/pages/assets/component-illustrations/DragAndDrop.svg';
2526
import Checkbox from '@react-spectrum/docs/pages/assets/component-illustrations/Checkbox.svg';
2627
import Button from '@react-spectrum/docs/pages/assets/component-illustrations/Button.svg';
2728

@@ -452,6 +453,13 @@ import {Table, TableHeader, TableBody, Column, Row, Cell, Button, Checkbox, Resi
452453
<Selection />
453454
</ExampleCard>
454455

456+
<ExampleCard
457+
url="dnd.html"
458+
title="Drag and drop"
459+
description="Concepts and interactions for an accessible drag and drop experience.">
460+
<DragAndDrop />
461+
</ExampleCard>
462+
455463
</section>
456464

457465
### Composed components

0 commit comments

Comments
 (0)