3cn-ecn / nantralPlatform

Nantral Platform is a website project for clubs, events and more in Centrale Nantes
https://nantral-platform.fr
MIT License
21 stars 2 forks source link

[BUG] Remove autofocus on Event page on going back #1079

Closed hydrielax closed 11 months ago

hydrielax commented 1 year ago

How to reproduce

2023-08-15 16 09 43

Expected behaviour

The scroll is at the position of the event and not reset to the top

How to solve?

The reset to the top is due to the SearchField, which has an autofocus prop. This prop focuses the field so that we can directly type in it, but it also scroll to this field to show the field (in which you are typing).

Note that the autofocus is disabled on mobile (we should keep that).

To solve it, use React Router to know if when you open the page you have clicked on a link or if you use the go back button. Then, update the autofocus prop accordingly to have the value true when opening from on a link on desktop, and false when using the go back button (or on mobile).