a-h / templ

A language for writing HTML user interfaces in Go.
https://templ.guide/
MIT License
8.26k stars 272 forks source link

Back button nav #94

Closed gedw99 closed 1 year ago

gedw99 commented 1 year ago

Am using templ with htmx .

anyone noticed that sone systems when you go back load the old page instantly and at the place ( in terms of scrolling ) where you were ?

delaneyj commented 1 year ago

@gedw99 stop being everywhere πŸ˜†

a-h commented 1 year ago

It looks like people used to use local storage to retain the position and use JavaScript to put it back: https://stackoverflow.com/questions/29203312/how-can-i-retain-the-scroll-position-of-a-scrollable-area-when-pressing-back-but

But that modern browsers have a built-in API: https://jaketrent.com/post/scroll-restoration-javascript/

I don't think there's anything for templ to do here though. 😁

gedw99 commented 1 year ago

Thanks @a-h

Will try out some of these approaches and PR back an example if it’s pertinent