Problem/Motivation

I am looking for a widget that will work as the chosen one does but with the option to autosubmit. This seems to have been possible with earlier versions of chosen ( e.g. Chosen 8.x-2.10 running on another site seems to be working this way )

Am using chosen on search_api view with facets as better exposed filters, and trying to use chosen on the selects and multiselects - neither will autosubmit (it works but i have to click submit button after each choice)

Is there any way to get the plugin to do this - maybe through a fapi override or something?

Comments

gsquirrel created an issue. See original summary.

myha’s picture

StatusFileSize
new478 bytes

Not sure it's properly solution, but for making it work I trigger 'change' event of the exposed form.

myha’s picture

StatusFileSize
new534 bytes

Updated my patch.

nagy.balint’s picture

dbielke1986’s picture

Same here. In earlier version it was possible, but not since switching to version 5.x

nagy.balint’s picture

So based on #3464069: Add Better Exposed Filters support
data-bef-auto-submit-exclude attribute was added, which was also in 4.x so by earlier version perhaps you meant 3.x

the issue that was solved by this is

As a consecuence, after updating to Better Exposed Filters to 6.0.4 or newer, and using Chosen on a select filter, makes the input search unusable because it auto-submits the form right after the user type just a character.

So then the solution here is to revert that change, but to solve the original issue in a better way.

gsquirrel’s picture

If solve the original issue is too challenging maybe this could be a tickbox option with a warning about that possible side effect? So that people who are willing to live with that can have autosubmit possible?

nagy.balint’s picture

If I understand correctly the issue I linked, if the search input field is enabled on the Chosen widget, then the autosubmit would completely break the widget.

And it seems that this module only adds this data-bef-auto-submit-exclude to the search input field.

Maybe this issue is not related to the BEF change after all then?

dbielke1986’s picture

Any ideas here? I would like to switch back from select2all, but this issue is blocking me from doing this.

nagy.balint’s picture

Actually it is better to fix this in the library.

It seems the issue is that in jQuery the change event was bubbling by default, but in vanillaJS the event is not bubbling by default, so we need to add that specifically.

Can you try this release to see if it fixes the issue?
https://github.com/noli42/chosen/releases/tag/3.0.3

If so then we can add it to the module, and i can make an npmjs release as well.

nagy.balint’s picture

Status: Active » Needs review
dbielke1986’s picture

@nagy.balint

Thank you for the information. I will check this next week and provide feedback.

nagy.balint’s picture

Status: Needs review » Fixed

likely solved by the 3.0.3 version of the library.

Can be reopened if not.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

leraa’s picture

Well, this is not fixed and the issue should not have been closed. We updated to Chosen 5.0.4 about two weeks ago and this bug surfaced for us. Our Chosen library is also listed as 5.0.4.

nagy.balint’s picture

Based on your comment, there seem to be a confusion about what I meant about the library.

In the README at https://git.drupalcode.org/project/chosen/-/blob/5.0.x/README.md?ref_typ...
if the library was installed with repository entry then it can be updated based on "Installation with repository entry" section.

As far as I know in Drupal it is still not possible to push an upgrade to the JS library in a module update. The composer merge plugin was for that reason, but it was very unpopular for some reason.
So this has to be done manually.
Some users use CDN, but that can be a security concern. Could be an alternative though in the future.

leraa’s picture

Version: 5.0.1 » 5.0.4

I tested the patch on a Drupal 11.3.7 site, using Chosen 5.0.4. It worked well.

leraa’s picture

Regarding #17, you're right, I didn't know that!