turbo-morph icon indicating copy to clipboard operation
turbo-morph copied to clipboard

Cannot morph node with turbo-frame within

Open pySilver opened this issue 2 years ago • 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.

pySilver avatar Nov 09 '22 13:11 pySilver

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

pySilver avatar Nov 09 '22 13:11 pySilver

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.

marcoroth avatar Nov 09 '22 14:11 marcoroth