marcoroth / turbo-morph

Morph action for Turbo Streams
MIT License
96 stars 1 forks source link

Cannot morph node with turbo-frame within #5

Open pySilver opened 1 year ago

pySilver commented 1 year ago

Not sure if it's a bug or expected behaviour but having this markup initially on page:

<turbo-frame id="product_list" src="_partials/product/list.html" loading="lazy" target="_top">This is the ORIGINAL product list that is expensive to load on initial page load</turbo-frame>

We cannot issue the following morph:

<turbo-stream action="morph" target="product_list">
  <template
    ><turbo-frame id="product_list"> This is the NEW product list</turbo-frame>
  </template>
</turbo-stream>

The following happens:

  1. Morph modifies content of a turbo frame but for some reason it triggers frame reload that in turn reverts original content.
pySilver commented 1 year ago

Interesting enough typical replace action does not have such side effects.

marcoroth commented 1 year ago

Hey @pySilver, thanks for opening this issue. This is definitely an interesting use-case!

Usually I would say, if the replace/update action serves your needs just use them over morph.

Though I still want to also make this work for the morph action as well. Or - at least - explain why it doesn't work.

I will take a look and come back to you with my results.