Skip to content
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

Combobox doesn't close if it is open and you press it #217

Open
robinfissum opened this issue Sep 8, 2020 · 0 comments
Open

Combobox doesn't close if it is open and you press it #217

robinfissum opened this issue Sep 8, 2020 · 0 comments

Comments

@robinfissum
Copy link

robinfissum commented Sep 8, 2020

The following block of code (in jquery.dj.selectable.js) doesn't seem to do what it is supposed to:

if (this.selectableType === 'combobox') { // Add show all items button button = this._comboButtonTemplate($input); button.insertAfter($input).click(function (e) { e.preventDefault(); // close if already visible if (self.widget().is(":visible")) { self.close(); } // pass empty string as value to search for, displaying all results self._search(""); $input.focus(); });

If the menu from the combobox is visible and you press the combobox again, then the menu opens again. It would be better if it closed itself. The reason is that self.widget().is(":visible") always evaluates to false. A possible fix may look something like:

if (this.selectableType === 'combobox') { // Adds a button that displays all possible menu options when pressed button = this._comboButtonTemplate($input); button.insertAfter($input).click(function (event) { event.preventDefault(); // Close dropdown menu if it is already visible and disable focus if (self.visible){ self.close(); $input.focus(); self.visible = false }else{ // pass empty string as value to search for, displaying all results self._search(""); $input.focus(); self.visible = true } });

In addition, it would be cool if the combobox- icon changed to "ui-icon-triangle-2-s" when the menu is displaying (I.e. a upside down triangle, indicating that the button now results in the menu closing).

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

No branches or pull requests

1 participant