You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[LiveComponent][Autocomplete] Adding support for libraries to play nicely together
This includes several important points:
A) In autocomplete, data-live-ignore was added so that, when a "live component" re-renders,
the element is not affected.
B) For morphdom, the node key was changed from "id" to "data-live-id". This was due to
a very complex "bad situation" that arised when autocomplete+live components. TomSelect
finds the label for the element and give it an id attribute, which helps with the
aria- attributes. However, this caused, on re-render, morphdom to think the "new label"
did not match the old label. This small difference caused the elements in the parent
div to be re-added one-by-one. Most importantly, a very innocent fromEl.appendChild(selectEl)
is called deep in morphdom. In reality, selectEl already exists in fromEl... and the purpose
of this call is actually just to help order things in the correct way. However, appendChild()
caused the select element to momentarily be removed from the DOM then re-added. Stimulus
noticed this and disconnected and then reconnected the autocomplete controller, causing
the element to re-initialize (this, at the very least, would cause the element to lose focus).
Anyways, this whole bad situation (which, is a bit poorly handled by morphdom), was caused
by morphdom being confused by the "id" attribute on the label, which is present in the DOM
but not in the re-rendered HTML. To avoid side effects like this, the nodeKey was changed
to data-live-id.
C) In live components, we also fixed a bug where if an element had data-live-ignore, it could
be, incorrectly, removed on re-render if not present.
0 commit comments