Skip to content

Commit 700ad3b

Browse files
authored
DnD: Focus initial drop target when using iOS VO (#3283)
* go to first droppable if using VO * update test
1 parent 3732448 commit 700ad3b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/@react-aria/dnd/src/DragManager.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {announce} from '@react-aria/live-announcer';
1414
import {ariaHideOutside} from '@react-aria/overlays';
1515
import {DragEndEvent, DragItem, DropActivateEvent, DropEnterEvent, DropEvent, DropExitEvent, DropItem, DropOperation, DropTarget as DroppableCollectionTarget} from '@react-types/shared';
1616
import {getDragModality, getTypes} from './utils';
17+
import {getInteractionModality} from '@react-aria/interactions';
1718
import {useEffect, useState} from 'react';
1819

1920
let dropTargets = new Map<Element, DropTarget>();
@@ -69,8 +70,10 @@ export function beginDragging(target: DragTarget, formatMessage: (key: string) =
6970
dragSession = new DragSession(target, formatMessage);
7071
requestAnimationFrame(() => {
7172
dragSession.setup();
72-
73-
if (getDragModality() === 'keyboard') {
73+
if (
74+
getDragModality() === 'keyboard' ||
75+
(getDragModality() === 'touch' && getInteractionModality() === 'virtual')
76+
) {
7477
dragSession.next();
7578
}
7679
});

packages/@react-aria/dnd/test/dnd.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,7 @@ describe('useDrag and useDrop', function () {
23552355

23562356
fireEvent.click(draggable);
23572357
act(() => jest.runAllTimers());
2358-
expect(document.activeElement).toBe(draggable);
2358+
expect(document.activeElement).toBe(droppable);
23592359
expect(draggable).toHaveAttribute('aria-describedby');
23602360
expect(document.getElementById(draggable.getAttribute('aria-describedby'))).toHaveTextContent('Dragging. Double tap to cancel drag.');
23612361
expect(announce).toHaveBeenCalledWith('Started dragging. Navigate to a drop target, then double tap to drop.');

0 commit comments

Comments
 (0)