diff --git a/assets/js/session/index.js b/assets/js/session/index.js index 3686114d7..c37d07968 100644 --- a/assets/js/session/index.js +++ b/assets/js/session/index.js @@ -472,6 +472,14 @@ function focusCellFromUrl(hook) { if (getCellById(cellId)) { setFocusedCell(hook, cellId); } + } else { + // Explicitly scroll to the target element + // after the loading finishes + const htmlId = hash.replace(/^#/, ""); + const element = document.getElementById(htmlId); + if (element) { + element.scrollIntoView(); + } } } diff --git a/lib/livebook_web/live/session_live/section_component.ex b/lib/livebook_web/live/session_live/section_component.ex index 5aa08e2ce..19a46368a 100644 --- a/lib/livebook_web/live/session_live/section_component.ex +++ b/lib/livebook_web/live/session_live/section_component.ex @@ -4,13 +4,12 @@ defmodule LivebookWeb.SessionLive.SectionComponent do def render(assigns) do ~L"""