In this day and age being a developer and being in a fast-paced environment we have to deliver as quickly as possible.
While trying to deliver qui...
For further actions, you may consider blocking this person and/or reporting abuse
No. The expected behaviour when you click 'back' is to be returned to the place from where you went 'forward' - scroll position and all. If you prevent this from happening, you are breaking the normal, expected behaviour of the browser. You shouldn't do this, and it is extremely irritating for the user
Thanks Jon for commenting, the situation which i have discussed here is different, hence i mentioned not scroll to the top as expected.
For eg:
You have a header and a footer in between you have multiple small components and all the data is powered by making API calls its dynamic in nature.
Let us say you click on a small component which is just above the footer and you navigated to a new page, on the new page when you click on back you come back to the page and your scroll would be near the footer.
Since the page is very dynamic and we make API call every time the page loads and till the API has finished we show a loader or shimmer, since the page has scrolled down near the footer the user does not know whats happening above, then new data would get loaded, hence confusing the user more.
I agree with your point completely that resetting the scroll position is extremely irritating for the user, its a valid argument for page which is not very dynamic.
That is the reason by default browser set
window.history.scrollRestoration
toauto
in order to maintain the user behaviour, but yes the case i have mentioned is a different one where we need to reset it to manual.If this causes an issue for your page, you're doing things wrong
No problem, i hope you write a good article on how to resolve this in future so that i can look and make things right. We are here to learn always :)
that is awesome! thanks for sharing
Thanks Daniel, keep sharing it with your dev friends.
Very helpful and relatable. Bookmarked
Thanks mate, glad you liked it, keep sharing praveen
Awesome!
Thanks Nikhil, keep sharing it with your dev friends.
Great article 👍
Thanks ronak, appreciated
Awesome collection of tips 👏🏻
Thanks Sarah, keep sharing it with your dev friends.
Learnt a lot from this! Looking forward to your next article buddy :)
Thanks yusuf, always keep learning