Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve scroll position when using the back to search results link #576

Open
1 task
sarayourfriend opened this issue Apr 14, 2022 · 6 comments
Open
1 task
Labels
♿️ aspect: a11y Concerns related to the project's accessibility ✨ goal: improvement Improvement to an existing user-facing feature help wanted Open to participation from the community 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: frontend Related to the Nuxt frontend ⌨️ tech: typescript Involves TypeScript
Projects

Comments

@sarayourfriend
Copy link
Contributor

sarayourfriend commented Apr 14, 2022

Problem

The "scroll to top" behaviour happens every time you use the back to results button. This does not follow the standard behaviour of back/forward navigation in the browser where page scroll position is preserved. It does work with the browser back/forward button, so the back to results button should mirror that behaviour.

To fix this, the back to results button should be implemented using standard browser back button when possible.

Implementation

  • 🙋 I would be interested in implementing this feature.
@sarayourfriend sarayourfriend added 🟩 priority: low Low priority and doesn't need to be rushed ✨ goal: improvement Improvement to an existing user-facing feature 🕹 aspect: interface Concerns end-users' experience with the software labels Apr 14, 2022
@krysal krysal changed the title Only scroll single results page to top when navigating to a related result via the link, but not when using browser back/forward navigation Preserve scroll position when using browser back/forward navigation or the back to search results link Apr 29, 2022
@anton202 anton202 removed their assignment Dec 6, 2022
@obulat obulat transferred this issue from WordPress/openverse-frontend Feb 22, 2023
@obulat obulat added the 🧱 stack: frontend Related to the Nuxt frontend label Feb 22, 2023
@zackkrida
Copy link
Member

Update: the browser back/forward buttons appear to be working correctly here, but our "Back to results" link on single images does not:

CleanShot 2023-02-22 at 10 40 39

dhruvkb pushed a commit that referenced this issue Apr 14, 2023
* Add a draft science_museum_2.py script
* Improve Science museum script and fix tests
* Use the ingester class in the provider workflow
* Apply changes from the code review
* Move RECORDS_IDS to init and recreate it on every test
* Fix RECORD[S]_IDS typo
* Handle lack of "multimedia" key and a blank list as the value

Signed-off-by: Olga Bulat <[email protected]>
Co-authored-by: Madison Swain-Bowden <[email protected]>
@devinmaeztri
Copy link
Member

I'm using Openverse this morning, searching for about 7 topics. If I clicked on an image then wanted to go back to look for more images, I clicked on the Back to results button, but every time it would bring me to the top page position. It means I had to scroll down again to go back to where I was at.

Just now I tried again searching for cats and experienced the same behavior.
Screenshot 2023-10-25 at 11 04 03

@sarayourfriend sarayourfriend changed the title Preserve scroll position when using browser back/forward navigation or the back to search results link Preserve scroll position when using the back to search results link Oct 26, 2023
@sarayourfriend sarayourfriend added good first issue New-contributor friendly 🟨 priority: medium Not blocking but should be addressed soon ♿️ aspect: a11y Concerns related to the project's accessibility help wanted Open to participation from the community ⌨️ tech: typescript Involves TypeScript and removed 🟩 priority: low Low priority and doesn't need to be rushed 🕹 aspect: interface Concerns end-users' experience with the software good first issue New-contributor friendly labels Oct 26, 2023
@sarayourfriend
Copy link
Contributor Author

Thanks for sharing your experience with this bug @devinmaeztri.

I've updated the labels to reflect that this is an accessibility issue, as we're breaking the expected behaviour of the browser in an interface item that technically duplicates built-in browser features. They should behave the same. I've also added the help wanted label, escalated the priority to medium (particularly as the issue has been open for a long time) and moved it into our todo column of issues to tackle within the next few weeks.

@devinmaeztri
Copy link
Member

Thank you @sarayourfriend!

@AetherUnbound
Copy link
Contributor

We discussed this during our priorities meeting today - ultimately this issue would be addressed by way of moving the individual search results into a model (#429). However, an implementation with our current framework could be quite complex, and @obulat and @dhruvkb expressed that there might be additional concerns about having to adjust the implementation significantly after upgrading to Nuxt 3 (#411). If I'm incorrect about the potential complexity around implementation here please let me know!

@devinmaeztri thank you again for re-raising this and we will address this issue as soon as we can!

@sarayourfriend
Copy link
Contributor Author

Vue-router doesn't support this behaviour, it turns out: vuejs/router#1189 (comment)

It's computeScrollPosition function, which it uses to decide where on the page to scroll to after navigating forward/back, always uses window.pageXOffset and window.pageYOffset, and this is not configurable.

https://github.com/vuejs/router/blob/main/packages/router/src/scrollBehavior.ts#L71

I don't think solving it would change very much between Nuxt 2 and 3 because the problem is fundamentally in vue router. I'd like to take a quick, time-boxed attempt at this, because as I said, I think the issue will persist, and the single result modal is (a) blocked and (b) almost certainly far more complex than this issue...

The recommended implementation in the vue router issue I've linked is to save the position ourselves and manually scroll the element. I think this is doable, but maybe I'm totally wrong.

@dhruvkb @obulat can y'all elucidate your concerns over needing to change the implementation for nuxt 3? Have y'all found something about the implementation of Nuxt 3's routing that makes it significantly different from vue router's behaviour in Nuxt 2? As I understand it, we'd need to save the scroll position of the search results element and then retrieve it when the page loads. Would that kind of thing be super different between Nuxt 2 and 3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
♿️ aspect: a11y Concerns related to the project's accessibility ✨ goal: improvement Improvement to an existing user-facing feature help wanted Open to participation from the community 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: frontend Related to the Nuxt frontend ⌨️ tech: typescript Involves TypeScript
Projects
Status: 📋 Backlog
Openverse
  
Backlog
Development

No branches or pull requests

6 participants