Skip to content

Commit 7237ff2

Browse files
author
Jan Petr
authored
Merge pull request #956 from algolia/fix/mobile_hover
Handle buggy onclick event on iOS
2 parents a902a43 + 979bbc8 commit 7237ff2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

js/algoliasearch/autocomplete.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,20 @@ document.addEventListener("DOMContentLoaded", function(event) {
105105
fixAutocompleteCssSticky(menu);
106106
});
107107
});
108+
109+
// Hack to handle buggy onclick event on iOS
110+
$(algoliaConfig.autocomplete.selector).each(function () {
111+
var data = $(this).data('aaAutocomplete');
112+
var dropdown = data.dropdown;
113+
var suggestionClass = '.' + dropdown.cssClasses.prefix + dropdown.cssClasses.suggestion;
114+
115+
dropdown.$menu.on('touchstart', suggestionClass, function(e) {
116+
e.preventDefault();
117+
e.stopPropagation();
118+
119+
var url = $(this).find('a').attr('href');
120+
location.assign(url);
121+
});
122+
});
108123
});
109124
});

0 commit comments

Comments
 (0)