Skip to content

Commit b1af1ed

Browse files
annouce first drop target after drag start (#3191)
Co-authored-by: Robert Snow <[email protected]>
1 parent a0a88da commit b1af1ed

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ class DragSession {
157157
private restoreAriaHidden: () => void;
158158
private formatMessage: (key: string) => string;
159159
private isVirtualClick: boolean;
160+
private initialFocused: boolean;
160161

161162
constructor(target: DragTarget, formatMessage: (key: string) => string) {
162163
this.dragTarget = target;
@@ -168,6 +169,7 @@ class DragSession {
168169
this.onClick = this.onClick.bind(this);
169170
this.onPointerDown = this.onPointerDown.bind(this);
170171
this.cancelEvent = this.cancelEvent.bind(this);
172+
this.initialFocused = false;
171173
}
172174

173175
setup() {
@@ -446,6 +448,13 @@ class DragSession {
446448

447449
item?.element.focus();
448450
this.currentDropItem = item;
451+
452+
// Annouce first drop target after drag start announcement finishes.
453+
// Otherwise, it will never get announced because drag start announcement is assertive.
454+
if (!this.initialFocused) {
455+
announce(item?.element.getAttribute('aria-label'), 'polite');
456+
this.initialFocused = true;
457+
}
449458
}
450459
}
451460

0 commit comments

Comments
 (0)