Skip to content

Commit 2a2665f

Browse files
authored
Fix dragging in Android Talkback (#3491)
1 parent 2b51e8f commit 2a2665f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,17 +237,19 @@ export function useDrag(options: DragOptions): DragResult {
237237

238238
interactions = {
239239
...descriptionProps,
240-
onPointerDown({nativeEvent: e}) {
240+
onPointerDown(e) {
241241
// Try to detect virtual drags.
242242
if (e.width < 1 && e.height < 1) {
243243
// iOS VoiceOver.
244244
modalityOnPointerDown.current = 'virtual';
245245
} else {
246-
let rect = (e.target as HTMLElement).getBoundingClientRect();
246+
let rect = e.currentTarget.getBoundingClientRect();
247+
let offsetX = e.clientX - rect.x;
248+
let offsetY = e.clientY - rect.y;
247249
let centerX = rect.width / 2;
248250
let centerY = rect.height / 2;
249251

250-
if (Math.abs(e.offsetX - centerX) < 0.5 && Math.abs(e.offsetY - centerY) < 0.5) {
252+
if (Math.abs(offsetX - centerX) < 0.5 && Math.abs(offsetY - centerY) < 0.5) {
251253
// Android TalkBack.
252254
modalityOnPointerDown.current = 'virtual';
253255
} else {

0 commit comments

Comments
 (0)