I need help, so I have live page inside it a for loop that iterate an article component, the article component have phx_click that toggle a form to insert some data for this particular article.
I discovered that clicking on the article there a delay when I looked into the websocket I found that inbound connection have all the articles in diff.
this my render function in the article component
def render(assigns) do
~L"""
<p class="article-text" style="margin-bottom: 10px" id="<%= @article.id %>">
<%= for word <- body_to_words(@article.content) do %>
<span phx-click="word-clicked" phx-update="replace" phx-target="<%= @myself %>" phx-value-law="<%= @article.law_id %>" phx-value-article="<%= @article.id %>" phx-value-offset="<%= word.offset %>" >
<%= word.text %>
<%= if @show_toolbar && @article.id == elem(Integer.parse(@clicked_word.article), 0) && @clicked_word.offset == word.offset do%>
<span class="reference is-active">()</span>
<% end %>
</span>
<% references = Enum.filter(@article.references, fn ref -> ref.offset == word.offset end) %>
<%= if length(references) > 0 do %>
<%= if length(references) > 1 do %>
<span class="reference">
<%= for ref <- references do %>
<%= ref.text %>
<% end %>
</span>
<% else %>
<%= for ref <- references do %>
<span class="reference"><%= ref.text %> </span>
<% end %>
<% end %>
<% end %>
<% end %>
</p>
"""
end
and here part of the editor.
<div class="card">
<div class="card__body">
<div id="laws-<%= @counter %>" phx-update="append" class="stylesheet searchable-context">
<%= for article <- @articles do %>
<%= live_component @socket, ArticleComponent, article: article, show_toolbar: @show_toolbar, reference_changeset: @reference_changeset, id: article.id, clicked_word: @clicked_word %>
<% end %>
</div>
<div id="footer" phx-hook="InfiniteScroll">Load More</div>
</div>
</div>