Skip to content
New issue

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

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

Already on GitHub? # to your account

dropdown is opening for every keypress #2245

Open
risperdal opened this issue Feb 20, 2015 · 2 comments
Open

dropdown is opening for every keypress #2245

risperdal opened this issue Feb 20, 2015 · 2 comments

Comments

@risperdal
Copy link

I dont know if this done on purpose but in my form the f2 key is triggering filter function.

When user selects some item on dropdown and presses f2 key, it is filtering the form but the dropdown is opening.

The dropdown shouldnt toggled for every keypress.

the fix

 AbstractChosen.prototype.keyup_checker = function(evt) {
            var stroke, _ref;
            stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
            this.search_field_scale();
            switch (stroke) {
                case 8:
                    if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
                        return this.keydown_backstroke();
                    } else if (!this.pending_backstroke) {
                        this.result_clear_highlight();
                        return this.results_search();
                    }
                    break;
                case 13:
                    evt.preventDefault();
                    if (this.results_showing) {
                        return this.result_select(evt);
                    }
                    break;
                case 27:
                    if (this.results_showing) {
                        this.results_hide();
                    }
                    return true;
                case 9:
                case 38:
                case 40:
                case 16:
                case 91:
                case 17:
                    break;
                default:
                    //if not showing then do not toggle
                    if (this.results_showing) {
                        return this.results_search();
                    }
            }
        };
@tjschuck
Copy link
Member

Some other potentially-unexpected buttons that open Chosen: the option key, and turning off caps lock (weirdly, not turning on caps lock).

@braddunbar
Copy link
Contributor

FYI, I pulled a fix for the option key in #2475. 😺

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants