[htmx 4] Click events on elements with hx-get fail to trigger on iOS 15 Mobile Safari
Click/tap events on elements with hx-get fail to fire when opened in Mobile Safari on iOS 15 when using htmx 4. Downgrading the library to htmx 2 immediately resolves the issue without any changes to the HTML/CSS codebase.
To Reproduce Steps to reproduce the behavior:
- Create a simple button element with hx-get, hx-target, and hx-swap attributes:
<button type="button"
hx-get="/api/v1/schedule?offset=-1"
hx-target="#schedule-grid"
hx-swap="outerHTML"
hx-push-url="true">
← Previous
</button>
- Load the page on an iPhone running iOS 15 Mobile Safari
- Tap the button.
Expected behavior htmx should intercept the tap event, issue an asynchronous GET request to the specified endpoint, and swap the target DOM node (#schedule-grid)
Actual behavior Nothing happens upon tapping the button. No network request is initiated in the browser developer tools console
Environment: htmx version: htmx 4
Device: iPhone
OS: iOS 15
Browser: Mobile Safari
Server Stack: Server-Side Rendering
Additional context Replacing the script tag source from htmx 4 back to htmx 2.x instantly fixes the problem on the exact same device and markup, allowing touch events to trigger AJAX requests as expected
Source: bigskysoftware/htmx