# Scroll position changes on stream\_insert/4 when using LiveView streams

**URL:** <https://forum.elixirforum.com/t/scroll-position-changes-on-stream-insert-4-when-using-liveview-streams/61887>\
**Category:** Questions\
**Tags:** phoenix, streams, liveview\
**Created:** [February 25, 2024, 7:35pm UTC](https://forum.elixirforum.com/t/scroll-position-changes-on-stream-insert-4-when-using-liveview-streams/61887 "2024-02-25T19:35:44Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![coen.bakker](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/coen.bakker/32/39732_2.png) [@coen.bakker](https://forum.elixirforum.com/u/coen.bakker)\
**Post date:** [February 25, 2024, 8:00pm UTC](https://forum.elixirforum.com/t/scroll-position-changes-on-stream-insert-4-when-using-liveview-streams/61887/7 "2024-02-25T20:00:39Z")

</div>

So it also happens with in this version (removing my own database fetch to make it fully transparent). Also, not using a layout (app.html.heex).

```elixir
defmodule MyAppWeb.TempLive do
  use MyAppWeb, :live_view

  def mount(_, _, socket) do
    posts = [
      %{id: 1, message: "First post"},
      %{id: 2, message: "Second post"},
      %{id: 3, message: "Third post"},
      %{id: 4, message: "Fourth post"},
      %{id: 5, message: "Fifth post"},
      %{id: 6, message: "Sixth post"},
      %{id: 7, message: "Seventh post"},
      %{id: 8, message: "Eighth post"},
      %{id: 9, message: "Ninth post"},
      %{id: 10, message: "Tenth post"}
    ]

    {:ok, stream(socket, :posts, posts)}
  end

  def render(assigns) do
    ~H"""
    <div
      id="stream"
      phx-update="stream"
      class="flex flex-col gap-10"
    >
      <%= for {dom_id, post} <- @streams.posts do %>
        <div id={dom_id}>
          <p><%= post.message %></p>
          <button phx-click="update" phx-value-id={post.id}>Click</button>
        </div>
      <% end %>
    </div>
    """
  end

  def handle_event("update", %{"id" => id}, socket) do
    {:noreply, stream_insert(socket, :posts, %{id: id, message: "Updated message"})}
  end
end

```

---

_[View the full topic](https://forum.elixirforum.com/t/scroll-position-changes-on-stream-insert-4-when-using-liveview-streams/61887)._
