Closed touchclick not working in latest iOS Safari

DragonByte Tech

Well-known member
Licensed customer
Affected version
2.3.13
Problem
Given a HTML tag like this:
HTML:
<abbr data-xf-init="tooltip" data-trigger="hover focus touchclick" tabindex="0" role="button" class="bbc-abbr" data-original-title="2021-02-07 at 15:10" aria-label="2021-02-07 at 15:10" id="js-XFUniqueId12">11 minutes, 36 seconds</abbr>

You would expect tapping on this "link" to show the tooltip from data-original-title. This does not happen on Safari on iOS 27.2, due to a bug fix that got reverted thanks to the touchscreen Macs.

The problem is that Safari on iOS gives the wrong pointer type on the click event, and XenForo's touch check trusts that value.

How it fails
  1. touchclick only acts when the click looks like a touch (core_handlers.js:1445):
    Code:
    XF.onPointer(target, 'click.tooltip', e => {
        if (XF.isEventTouchTriggered(e)) { this.click(e) }
    })

  2. XF.onPointer works out the pointer type like this (core.js:567):
    e.xfPointerType = e.pointerType || target.getAttribute('data-xf-pointer-type') || ''
    The data-xf-pointer-type fallback, which is recorded on pointerdown, was added because older Safari sent click as a plain MouseEvent with no pointerType.
  3. Since Safari 18.2, click is a real PointerEvent. But on iOS a tap's click reports pointerType: "mouse", even though its pointerdown/pointerup say "touch" (WebKit bug 282988, reopened, plus a regression tracked in 287098). e.pointerType is now a non-empty string, so the fallback that holds the correct "touch" is never reached.
  4. isEventTouchTriggered() then returns false, so the click is ignored.
  5. The other triggers don't make up for it:
    • hover: the touch pointerover is skipped on purpose. The extra "mouse" pointerover iOS sends right after is also skipped by the iOS guard at core_handlers.js:1698.
    • focus: focusEnter falls back to XF.Feature.has('touchevents'), which is true on iOS, so it bails too.
So all three triggers are suppressed, and nothing happens on tap.

Core fix: in XF.onPointer, prefer the type recorded on pointerdown over e.pointerType for click events, e.g. target.getAttribute(dataKey) || e.pointerType || '' for click/auxclick/contextmenu. This also fixes core's own trigger: 'auto' span tooltips, which break the same way on iOS.

Diff
Diff:
--- a/js/xf/core.js
+++ b/js/xf/core.js
@@ -565,11 +565,17 @@
                 events = events.split(/\s+/)
             }
 
             const dataKey = 'data-xf-pointer-type'
+            const pointerActivatedEvents = ['click', 'auxclick', 'contextmenu']
 
             events.forEach(event => XF.on(target, event, e =>
             {
-                e.xfPointerType = e.pointerType || target.getAttribute(dataKey) || ''
+                const recordedType = target.getAttribute(dataKey)
+
+                // iOS Safari reports pointerType "mouse" on clicks from taps (WebKit bug 282988)
+                e.xfPointerType = (recordedType && pointerActivatedEvents.includes(e.type))
+                    ? recordedType
+                    : (e.pointerType || recordedType || '')
                 callback(e)
             }, options))
             XF.on(target, 'pointerdown', e => target.setAttribute(dataKey, e.pointerType), { passive: true })

Sources:
 
Automated triage: Closed

Thank you for reporting this issue. This was already changed for 2.3.14. Taps are now identified by the pointer type recorded when the finger touches down, not the type Safari reports on the click, which is the change you suggested. If tapping still doesn't show the tooltip on 2.3.14, please post a new report.

This is an automated assessment. A member of staff may review and update it.
 
Back
Top Bottom