How to disable LiveView updates while user is active?

currently when a user is doing stuff on the website (updating data, triggering background processes, using dropdowns), then a LV update can easily disrupt the user with its updates. by disrupt I mean user is scrolling a dropdown that decides to disappear.

i can appreciate one solution is having the dropdown variables in assigns, but I’m really hoping there’s a global “works everywhere always” solution.

a solution I could imagine is to just disable updates (or rather queue them up) while there’s any element with :active or :focus. i would even implement this myself if I could see a way to pause the updating process.

how have you handled user disrupting LV updates?

If you mean a LV update overwriting JS applied changes then the solution is to either use Phoenix.LiveView.JS or hook into the dom patching behaviour of LiveView to retain what you applied with JS like shown here: Maintain `<details>` native behaviour across LV updates · Issue #2349 · phoenixframework/phoenix_live_view · GitHub

my issue was actually with the live_select library BUT your solution is the correct answer to the question so I’ve marked it as the solution (also wasn’t aware of those hooks, nice).

if anyone’s curious about the live_select issue I’ve opened a PR here.

sorry for the trouble :slight_smile: