Skip to content

[SEARCH] ESC button breaks Search input #5596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
smartm0use opened this issue Jul 27, 2017 · 3 comments
Open

[SEARCH] ESC button breaks Search input #5596

smartm0use opened this issue Jul 27, 2017 · 3 comments

Comments

@smartm0use
Copy link

smartm0use commented Jul 27, 2017

https://jsfiddle.net/5uLqzspm

Did you notice that if you search for somethings and then press Esc, then you can't search again?

To make it working again you have to focusout and focusin...

@smartm0use smartm0use changed the title [SEARCH] [SEARCH] ESC button breaks Search input Jul 27, 2017
@awgv awgv added this to the Needs Milestone milestone Jul 28, 2017
@cemremengu
Copy link

Any workaround for this one?

@rubenanapu
Copy link

I could make this work by focusing on a "hidden" checkbox when esc is pressed, and then focusing again on the #search.
Something like:

<input type="checkbox" style="width: 0px" id="reset_search" >

<script>
        $(window).on('keyup', function(evt){
            if(evt.which == 27){
                $("#search").val('');
                $("#reset_search").focus();
                setTimeout(function(){
                    $("#search").focus();
                }, 50);
            }
        });
</script>

@ifaniqbal
Copy link

@rubenanapu, your answer is very helpful. Thank you.

The point is the input should loose focus then re-focus again. So, I do something like $(this).val('').blur().focus() when escape button pressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants