elm-select
elm-select copied to clipboard
Add event trigger
Context
When using the single menu variant it's very difficult to manage the opening and closing of the menu. The issue is that elm-select hides the menu when it is not focused.
If you have a trigger that opens the select menu like a dropdown, it is likely you would want this trigger to close the menu if it is open/visible. You might have some logic on the trigger such as -
if Select.isFocused state then
-- close the menu
else
-- open the menu
The issue is, internally, elm-select regards an unfocused menu closed and this happens as soon as the input loses focus. So if the menu is open and you click the trigger to close it, the menu will be regarded as closed before the trigger can close it. When the trigger msg runs it will see the menu is closed, so then try to open it which results in a flashing effect as the menu closes then immediately opens.
https://www.loom.com/share/9fb7a918687f47e990f0f9b1ca75839f
Proposed solution
Create a trigger event that consumers can add to their custom triggers, this internally could handle all the complexity of ensuring everything works as intended.
The InitialMousedown
properties could be leveraged to ensure things work as they should.
Something like this should be possible ...
view =
button [ Select.trigger SelectMsgHandler ] [ -- button stuff ]