marcoroth/turbo-morph

Cannot morph node with turbo-frame within

pySilver opened this issue · 2 comments

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.

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

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.