(e: TouchEvent)
| 366 | // If a touch happens on direct center of ComboBox input, might be virtual click from iPad so open ComboBox menu |
| 367 | let lastEventTime = useRef(0); |
| 368 | let onTouchEnd = (e: TouchEvent) => { |
| 369 | if (isDisabled || isReadOnly) { |
| 370 | return; |
| 371 | } |
| 372 | |
| 373 | // Sometimes VoiceOver on iOS fires two touchend events in quick succession. Ignore the second one. |
| 374 | if (e.timeStamp - lastEventTime.current < 500) { |
| 375 | e.preventDefault(); |
| 376 | inputRef.current?.focus(); |
| 377 | return; |
| 378 | } |
| 379 | |
| 380 | let rect = (getEventTarget(e) as Element).getBoundingClientRect(); |
| 381 | let touch = e.changedTouches[0]; |
| 382 | |
| 383 | let centerX = Math.ceil(rect.left + 0.5 * rect.width); |
| 384 | let centerY = Math.ceil(rect.top + 0.5 * rect.height); |
| 385 | |
| 386 | if (touch.clientX === centerX && touch.clientY === centerY) { |
| 387 | e.preventDefault(); |
| 388 | inputRef.current?.focus(); |
| 389 | state.toggle(null, 'manual'); |
| 390 | |
| 391 | lastEventTime.current = e.timeStamp; |
| 392 | } |
| 393 | }; |
| 394 | |
| 395 | // VoiceOver has issues with announcing aria-activedescendant properly on change |
| 396 | // (especially on iOS). We use a live region announcer to announce focus changes |
nothing calls this directly
no test coverage detected