Skip to content

Commit 1a8611b

Browse files
authored
iOS autocomplete double click fix (#1083)
1 parent 8edfd86 commit 1a8611b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

resources/js/vue-components.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ Vue.component('autocomplete', () => ({
5959
},
6060
delay: 0,
6161
}))
62+
if (import.meta.env.VITE_DISABLE_DOUBLE_CLICK_FIX !== 'true') {
63+
document.addEventListener('vue:loaded', function () {
64+
// Workaround double click bug on ipad & iphone: https://stackoverflow.com/questions/71535540/keyboard-doesnt-open-in-ios-on-focus
65+
if (
66+
['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) ||
67+
(navigator.userAgent.includes('Mac') && 'ontouchend' in document)
68+
) {
69+
// Simply load the autocomplete ~600ms after pageload so it won't impact pageload but will
70+
// Be fast enough that most users won't notice
71+
setTimeout(() => window.document.dispatchEvent(new window.Event('loadAutoComplete')), 600)
72+
}
73+
})
74+
}
6275
Vue.component('checkout-login', () => import('./components/Checkout/CheckoutLogin.vue'))
6376
Vue.component('login', () => import('./components/User/Login.vue'))
6477
Vue.component('listing', () => import('./components/Listing/Listing.vue'))

0 commit comments

Comments
 (0)