Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Input Search Field Won't Focus After Click Magnifying Glass › Reply To: Input Search Field Won't Focus After Click Magnifying Glass
April 28, 2022 at 1:45 pm
#37670
Keymaster
Thank you Dan! I have actually tested on a mobile device, and it worked just fine for some reason. Right now I don’t have an iPhone at hand, maybe that has something to do with the issue. Samsung and Huawei Chrome browsers seem to work just fine. IOS Safari is notoriously problematic with user generated events, such as input focus.
Maybe try this variation instead:
add_action('wp_footer', 'asp_footer_custom_script', 999999);
function asp_footer_custom_script() {
?>
<script>
(function($){
$('header .fa-search').on('click touchstart', function(){
setTimeout(function(){
let input = $('.dialog-widget-content .asp_m input.orig').get(0);
input.focus();
input.setSelectionRange(0, 9999);
}, 250);
});
})(WPD.dom);
</script>
<?php
}
This should explicitly capture the input.