Skip to content

Commit 44d7ebc

Browse files
authored
Drag and drop blog post (#3714)
1 parent 55440ca commit 44d7ebc

File tree

14 files changed

+479
-11
lines changed

14 files changed

+479
-11
lines changed
Lines changed: 166 additions & 0 deletions
Loading

packages/@react-aria/dnd/docs/OnDropPosition.svg

Lines changed: 1 addition & 1 deletion
Loading

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import DropOperation from './DropOperation.svg';
1212
import BetweenDropPosition from './BetweenDropPosition.svg';
1313
import OnDropPosition from './OnDropPosition.svg';
1414
import RootDropPosition from './RootDropPosition.svg';
15-
import DragPreview from './DragPreview.svg';
15+
import Anatomy from './Anatomy.svg';
1616
import DragAffordance from './DragAffordance.svg';
1717

1818
import {Layout} from '@react-spectrum/docs';
@@ -42,10 +42,7 @@ The drag source is responsible for providing one or more **drag items**, which s
4242

4343
While dragging, a **drag preview** is displayed under the user's mouse or finger to indicate the items being dragged. By default, this is a copy of the dragged element, but it can be customized. For example, when multiple items are dragged, they could be shown as a stack, or with a badge indicating the count.
4444

45-
<figure style={{display: 'flex', flexDirection: 'column', alignItems: 'center', margin: '20px 0'}}>
46-
<DragPreview role="img" aria-labelledby="drag-preview-caption" />
47-
<figcaption id="drag-preview-caption" style={{fontStyle: 'italic'}}>A custom drag preview representing multiple drag items.</figcaption>
48-
</figure>
45+
<Anatomy role="img" aria-label="Drag and drop anatomy diagram, showing drag source, drag preview, and drop target." />
4946

5047
There are several **drop operations** that can be performed as a result of a drag and drop interaction:
5148

@@ -76,7 +73,7 @@ Collection components built with hooks such as [useListBox](useListBox.html), [u
7673

7774
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.
7875

79-
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 long pressing to activate drag and drop mode, swiping between drop targets, and double tapping 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.
8077

8178
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.
8279

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ keywords: [drag, drop, dnd, drag and drop, aria, accessibility]
3838

3939
Drag and drop is a common UI interaction that allows users to transfer data between two locations by directly moving a visual representation on screen. It is a flexible, efficient, and intuitive way for users to perform a variety of tasks, and is widely supported across both desktop and mobile operating systems.
4040

41-
React Aria supports traditional mouse and touch based drag and drop, but also implements keyboard and screen reader friendly interactions. Users can press <Keyboard>Enter</Keyboard> on a draggable element to enter drag and drop mode. Then, they can press <Keyboard>Tab</Keyboard> to navigate between drop targets, and <Keyboard>Enter</Keyboard> to drop or <Keyboard>Escape</Keyboard> to cancel. Touch screen reader users can also drag by long pressing to activate drag and drop mode, swiping between drop targets, and double tapping to drop.
41+
React Aria supports traditional mouse and touch based drag and drop, but also implements keyboard and screen reader friendly interactions. Users can press <Keyboard>Enter</Keyboard> on a draggable element to enter drag and drop mode. Then, they can press <Keyboard>Tab</Keyboard> to navigate between drop targets, and <Keyboard>Enter</Keyboard> to drop or <Keyboard>Escape</Keyboard> 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.
4242

4343
See the [drag and drop introduction](dnd.html) to learn more.
4444

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ keywords: [drag, drop, dnd, drag and drop, aria, accessibility]
4242

4343
Collection components built with hooks such as [useListBox](useListBox.html), [useTable](useTable.html), and [useGridList](useGridList.html) can support drag and drop interactions. Users can drag multiple selected items at once, or drag individual non-selected items.
4444

45-
React Aria supports traditional mouse and touch based drag and drop, but also implements keyboard and screen reader friendly interactions. Users can press <Keyboard>Enter</Keyboard> on a draggable element to enter drag and drop mode. Then, they can press <Keyboard>Tab</Keyboard> to navigate between drop targets, and <Keyboard>Enter</Keyboard> to drop or <Keyboard>Escape</Keyboard> to cancel. Touch screen reader users can also drag by long pressing to activate drag and drop mode, swiping between drop targets, and double tapping to drop.
45+
React Aria supports traditional mouse and touch based drag and drop, but also implements keyboard and screen reader friendly interactions. Users can press <Keyboard>Enter</Keyboard> on a draggable element to enter drag and drop mode. Then, they can press <Keyboard>Tab</Keyboard> to navigate between drop targets, and <Keyboard>Enter</Keyboard> to drop or <Keyboard>Escape</Keyboard> 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.
4646

4747
See the [drag and drop introduction](dnd.html) to learn more.
4848

0 commit comments

Comments
 (0)