Choices-js / Choices

A vanilla JS customisable select box/text input plugin ⚡️
https://choices-js.github.io/Choices/
MIT License
6.16k stars 607 forks source link

to remove selected item we should click on it twice in a row (choices with Adjax-history in drupal) #1139

Open KateKarpenko opened 10 months ago

KateKarpenko commented 10 months ago

Hello community! I'm wondering if anyone also experiences the issue of using choices.js with turned-on Adjax-history on Drupal view? I encountered the problem that once after selecting a value in the exposed filter (on which is applied choices.js) to remove that item from the filter I had to click twice in a row. Usual one click somehow doesn't reload a page and this item is still visible as selected (but in URL I can confirm it removes the value of this item).

As I figured it out, if I turn off Adjax-history and keep only Ajax - then everything works as expected. But I don't want to sacrifice of ajax-history. Let me know please any ideas/thoughts. Thanks!

I use choices on a select element (tried both single and multiple selections) in Drupal10

const filterSubject = context.querySelector('select[name="test_filter[]"]');

    new Choices(filterSubject, {
      renderChoiceLimit: -1,
      removeItemButton: true,
      allowHTML: false,
      placeholderValue: "Subject",
    });

Expected behaviour One click should remove the selected item from the filter immediately and Ajax should update a page