LiveView tries to be somewhat smart when patching the HTML by sending down only the dynamic parts. But on the client it generates the new HTML and morphs it into the DOM quite crudely (and inefficiently, but that's another can of worms).
I've seen a workaround for this, by notifying the server of the change via an event, mirroring of sorts. But this is messy, and can require reimplementing the same conditional template logic on the backend.