actually using just the base example jsfiddle you can see this issue: https://jsfiddle.net/shentao/jqofkzxc/
clicking on the body of the closed multiselect opens the multiselect. Clicking again does not close it.
manually triggering a click on every element with javascript will not close it (try Array.from(document.querySelectorAll('.multiselect *')).forEach(e => e.click()), such as at https://jsfiddle.net/pet9zk87/).
We need a documented, exposed way to programmatically open and close multiselects
Opening and closing is based on focus. Add focus to open it, remove focus to close.
https://jsfiddle.net/shentao/mnphdt2g/
The API might be extended in the 3.0 release.
that's great. add focus to what though? there are many elements that are generated?
Adding focus to the root multiselect element is enough, just like in the example.
What about when it's not a searchable multiselect ? The example does not seems to work in that case.
Would be nice to add this to the documentation.
im not sure, the docs section on programmtic control makes sense,
first - the toggle, just focuses and blurs after 1000ms. that doesn't seem like the expected outcome of toggling between open and close
Also from a functional perspective, this is triggering the "click outside to close" feature of multi-select. Causing a flicker of the select options.
Could it be possible to allow FULL programatic control of multi-select by adding a option to turn off the "click outside to close" behavior
:)
It is possible with the currently in-progress version of v3. There is however no ETA when this ships. tl;dr; it allows to provide your own UI implementation for the whole thing. Also focus is no longer something that triggers the multiselect to open.
@shentao thanks for taking the time to respond, i look forward to v3
Most helpful comment
Opening and closing is based on focus. Add focus to open it, remove focus to close.
https://jsfiddle.net/shentao/mnphdt2g/
The API might be extended in the 3.0 release.