- Affected version
- 2.3.13
Problem
Given a HTML tag like this:
You would expect tapping on this "link" to show the tooltip from
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
Core fix: in
Diff
Sources:
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
- 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) } })
XF.onPointerworks out the pointer type like this (core.js:567):
e.xfPointerType = e.pointerType || target.getAttribute('data-xf-pointer-type') || ''
Thedata-xf-pointer-typefallback, which is recorded onpointerdown, was added because older Safari sent click as a plainMouseEventwith no pointerType.- Since Safari 18.2, click is a real PointerEvent. But on iOS a tap's click reports
pointerType: "mouse", even though itspointerdown/pointerupsay "touch" (WebKit bug 282988, reopened, plus a regression tracked in 287098).e.pointerTypeis now a non-empty string, so the fallback that holds the correct "touch" is never reached. isEventTouchTriggered()then returns false, so the click is ignored.- 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.
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: