Capturing a click when performing a live patch

Hi! My liveview has a popup menu with a link that initiates a live patch (<.link patch={...}>link text</.link>), and when this link is clicked I’d like to hide the menu. At first, I thought I might be able to use a phx-click binding with a JS.hide utility command to hide the menu, but it appears that a click event does not get triggered in this case. Anchor tags without an href can get picked up by phx-click, but it appears that when you have a non-empty href (like with live patches), one needs to try something else.

What do people think is a good way to do this? I realize that handle_params will get called as part of the live patch, and I could update some boolean on the socket that sets the visibility of the menu, but it seems like overkill to have to manage this parameter on the socket when normally I’d just handle this client-side with Phoenix’s JS commands.

Is your LiveView version 0.18.x? Previous versions have a bug that ignores the click that “wraps” a live patch or live redirect.

Yeah, my version of LiveView is 0.18.2