HermanMartinus / bearblog

Free, no-nonsense, super fast blogging.
MIT License
2.7k stars 77 forks source link

Keep scroll position after saving draft #191

Closed fr0gs closed 2 years ago

fr0gs commented 2 years ago

Hello,

When saving a draft post the scroll is reset to the beginning of the text area. It would be nice to keep the scroll position in the line where the cursor was.

Bearblog rocks!

Esteban

HermanMartinus commented 2 years ago

Thanks Esteban :)

This is the one problem with synchronous pages, but I have some ideas on how to make this better. I'll give it some thought 👍

HermanMartinus commented 2 years ago

Give it a spin now. It maintains the scroll position of the textarea on save, although not the page scroll which I think I'll add if necessary.

fr0gs commented 2 years ago

I can try to whip something up myself as a PoC if needed.

HermanMartinus commented 2 years ago

I think this works appropriately with very little added complexity. It just stores the last scroll position of the textarea and resets it on load. The page scroll is a bit more finicky as it's browser dependent, but also not necessary unless publishing on a smaller screen (like a mobile phone). Let me know what your experience is using this addition and close the issue if you're satisfied :)

fr0gs commented 2 years ago

Works as a charm! sorry for the delay.