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

Nested LiveView doesn't work in table #229

Closed
ruudk opened this issue May 25, 2019 · 2 comments
Closed

Nested LiveView doesn't work in table #229

ruudk opened this issue May 25, 2019 · 2 comments

Comments

@ruudk
Copy link
Contributor

ruudk commented May 25, 2019

Environment

  • Elixir version (elixir -v): Elixir 1.8.2 (compiled with Erlang/OTP 21)
  • Phoenix version (mix deps): Latest master #90d240f
  • NodeJS version (node -v): v10.15.2
  • NPM version (npm -v): 6.9.0
  • Operating system: macOS

Actual behavior

I render my liveview like this:

<table>
        <%= for item <- section.items do %>
            <%= live_render(@socket, AppWeb.Live.Checklist.TaskRow, container: {:tbody, []}, child_id: item.id, session: %{account: @account, user: @user, checklist: @checklist, item: item}) %>
        <% end %>
</table>

As you can see, I use the container property to prevent the creation of a <div> inside <table>.

The problem is that static_render,disconnected_nested_static_render and connected_nested_static_render always create <div class="phx-loader"></div>.

The JS lib uses

this.loader = this.el.nextElementSibling

to find that loader and that doesn't work when it's a div (as it's invalid to have a div inside a table).

When I change the <div> in static_render,disconnected_nested_static_render and connected_nested_static_render to this:

<%= Phoenix.HTML.Tag.content_tag(tag, "", [class: "phx-loader"]) %>

it continues.

The HTML is valid, but now the first load from the Websocket removes the <tr> and produces invalid HTML again:
Screenshot 2019-05-25 at 14 03 56

There is no <tr> tag anymore:
Screenshot 2019-05-25 at 14 05 19

Expected behavior

LiveView doesn't play nicely when the LV is a table row. I think it's a common usecase for LV's.

@chrismccord
Copy link
Member

This will be fixed soon, when the pushstate stuff lands where I have updated the loader to use the existing container and css pseudo elements. Thanks!

@chrismccord
Copy link
Member

Dup of #193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants