clerk icon indicating copy to clipboard operation
clerk copied to clipboard

Scroll position lost after browser refresh / error popup

Open yuhan0 opened this issue 4 months ago • 0 comments

Repro:

  • Have clerk show the following file on a small browser window such that it doesn't fit on a single page, and scroll to the bottom where the assoc block is visible.
(ns repro.scroll
  (:require [nextjournal.clerk :as clerk]))

:long
:document
:with
:lots
:of
:cells

(assoc {:current :position}
       :in :document
       ;; whoops
       )
       
(comment
  (clerk/show! *ns*))
  • Pretend to have made an error while editing the document by uncommenting the ;;whoops line
  • Save and eval clerk/show!
  • Browser page transforms into lots of scary red stacktraces
  • Fix the error by commenting the line back out.

Expected:

  • Last scroll position is preserved, such that the 'current' block being worked on remains visible.

Actual:

  • Scroll position is reset to top of page , user has to manually scroll back to where they were (usually at the bottom of a file)

Additional notes:

Scroll position should also be restored after showing a different namespace and returning back to the original, or after manually refreshing the page. (note that most websites display this behaviour)

yuhan0 avatar Apr 07 '24 10:04 yuhan0