bigskysoftware / idiomorph

A DOM-merging algorithm
BSD 2-Clause "Simplified" License
693 stars 33 forks source link

Focused element deleted by morph #55

Open pdf opened 4 months ago

pdf commented 4 months ago

I'm using htmx and am looking for more granular DOM updates. After installing the htmx extension from this project and enabling it via hx-swap="morph" on the relevant element, the morph occurs however the currently focused element is completely deleted from the DOM.

This happens regularly when a child input element value change triggers a swap of the parent, since the input will always be focused during the swap.

If I specify hx-swap="morph:{ignoreActive:true}" this behaviour is avoided, but that seems like a hack, and (IIUC) will ignore changes to the active element that sent by the server, which is undesirable in this case.