Stimulus-use: useClickOutside and useTransition

Have these both on a dropdown, but am running into an issue. Steps are:

  • click button for dropdown which runs the transition toggle
  • useTransition is hit first and starts to shows dropdown menu (no longer hidden)
  • useClickOutside (with onlyVisible: true) then fires but because menu has already started to show, it then fires and closes the menu instantly

Is there a best practice solution here?

So I got it to work by using the enterActive, enterTo, and enterFrom options to apply a class that useClickOutside could watch for. In the end though had to abandon because useTransition doesn’t support multiple targets and am using el-transition now instead.