mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-15 02:24:04 +00:00
fix(core): delay blur event for search suggestions
This is a hacky way to fix fix #404 and #410. By introducing a delay to the function to dismiss the suggestions, users on Safari should be able to click the link properly.
This commit is contained in:
parent
f505f30b89
commit
9d8a631f44
|
@ -304,21 +304,23 @@ function initTypeahead( searchForm, input ) {
|
|||
};
|
||||
|
||||
const onBlur = function ( event ) {
|
||||
const clickInside = typeahead.contains( event.relatedTarget );
|
||||
const focusIn = typeahead.contains( event.relatedTarget );
|
||||
|
||||
if ( !clickInside ) {
|
||||
searchInput.setAttribute( 'aria-activedescendant', '' );
|
||||
|
||||
typeahead.classList.remove( expandedClass );
|
||||
searchInput.removeEventListener( 'keydown', keyboardEvents );
|
||||
searchInput.removeEventListener( 'blur', onBlur );
|
||||
if ( !focusIn ) {
|
||||
// HACK: On Safari, users are unable to click any links because the blur
|
||||
// event dismiss the links before it is clicked. This should fix it.
|
||||
setTimeout( () => {
|
||||
searchInput.setAttribute( 'aria-activedescendant', '' );
|
||||
typeahead.classList.remove( expandedClass );
|
||||
searchInput.removeEventListener( 'keydown', keyboardEvents );
|
||||
searchInput.removeEventListener( 'blur', onBlur );
|
||||
}, 10 );
|
||||
}
|
||||
};
|
||||
|
||||
const onFocus = function () {
|
||||
// Refresh the typeahead since the query will be emptied when blurred
|
||||
updateTypeahead( messages );
|
||||
|
||||
typeahead.classList.add( expandedClass );
|
||||
searchInput.addEventListener( 'keydown', keyboardEvents );
|
||||
searchInput.addEventListener( 'blur', onBlur );
|
||||
|
|
Loading…
Reference in a new issue