Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute class is ignored when loading frame #830

Closed
benzen opened this issue Dec 25, 2022 · 4 comments
Closed

Attribute class is ignored when loading frame #830

benzen opened this issue Dec 25, 2022 · 4 comments

Comments

@benzen
Copy link

benzen commented Dec 25, 2022

If i have a turbo frame declared like this in my main page

<div class="parentElement">
  <turbo-frame 
                  th:src="@{/someUrl}" 
                  id="some-id"/>
</div>

When this frame is loaded, if my description of this frame looks like this

<turbo-frame id="some-id class="some-nice-looking-class">
....
</turbo-frame>

Even if everything is correctly wired with my backend, the class some-nice-looking-class will not be applied in my main page.

Depending on you system on class, this could be a non issue, since you can always put the same class on element below.
But some css style system require a direct link between element with certain classes.

I assume that all attribute will exibit the same behavior, but I did'nt test that assumption.

I think the good thing to do is to merge previously set attributes with the new attributes .

@seanpdoyle
Copy link
Contributor

seanpdoyle commented Dec 25, 2022

Frame elements are currently rendered with the same "action" as a <turbo-stream action="update"> element. The underlying renderer extracts the contents of the incoming frame and uses them to replace the current frame's contents. The <turbo-frame> element itself remains unchanged, save for its [src], [busy], and [complete] attributes that expose the state of the the navigation or form submission lifecycle.

The concept of a different rendering style was explored in #146. For example, to achieve the behavior you're describing, you're render the new frame with action="replace" semantics instead of action="update" semantics.

@benzen
Copy link
Author

benzen commented Dec 26, 2022

thanks for the link, very interesting to follow the tought process on this.

The way in thought about it is the same as turbo loading a complete page.
When navigating from one page to the next, headers are merged between the previous page and the next. And the content is "replaced".

I imagined turbo would have done the same with the element turbo-frame attributes and it's content.

@seanpdoyle
Copy link
Contributor

@benzen
Copy link
Author

benzen commented Dec 29, 2022

I think this would be a great addition to the doc.

@benzen benzen closed this as completed Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants