(e: PointerEvent)
| 650 | }; |
| 651 | |
| 652 | let onPointerUp = (e: PointerEvent) => { |
| 653 | if ( |
| 654 | e.pointerId === state.activePointerId && |
| 655 | state.isPressed && |
| 656 | e.button === 0 && |
| 657 | state.target |
| 658 | ) { |
| 659 | if ( |
| 660 | nodeContains(state.target, getEventTarget(e) as Element) && |
| 661 | state.pointerType != null |
| 662 | ) { |
| 663 | // Wait for onClick to fire onPress. This avoids browser issues when the DOM |
| 664 | // is mutated between onPointerUp and onClick, and is more compatible with third party libraries. |
| 665 | // https://github.com/adobe/react-spectrum/issues/1513 |
| 666 | // https://issues.chromium.org/issues/40732224 |
| 667 | // However, iOS and Android do not focus or fire onClick after a long press. |
| 668 | // We work around this by triggering a click ourselves after a timeout. |
| 669 | // This timeout is canceled during the click event in case the real one fires first. |
| 670 | // The timeout must be at least 32ms, because Safari on iOS delays the click event on |
| 671 | // non-form elements without certain ARIA roles (for hover emulation). |
| 672 | // https://github.com/WebKit/WebKit/blob/dccfae42bb29bd4bdef052e469f604a9387241c0/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm#L875-L892 |
| 673 | let clicked = false; |
| 674 | let timeout = setTimeout(() => { |
| 675 | if (state.isPressed && state.target instanceof HTMLElement) { |
| 676 | if (clicked) { |
| 677 | cancelEvent(e); |
| 678 | } else { |
| 679 | focusWithoutScrolling(state.target); |
| 680 | state.target.click(); |
| 681 | } |
| 682 | } |
| 683 | }, 80); |
| 684 | // Use a capturing listener to track if a click occurred. |
| 685 | // If stopPropagation is called it may never reach our handler. |
| 686 | addGlobalListener(e.currentTarget as Document, 'click', () => (clicked = true), true); |
| 687 | state.disposables.push(() => clearTimeout(timeout)); |
| 688 | } else { |
| 689 | cancelEvent(e); |
| 690 | } |
| 691 | |
| 692 | // Ignore subsequent onPointerLeave event before onClick on touch devices. |
| 693 | state.isOverTarget = false; |
| 694 | } |
| 695 | }; |
| 696 | |
| 697 | let onPointerCancel = (e: PointerEvent) => { |
| 698 | cancelEvent(e); |
nothing calls this directly
no test coverage detected