TheOdinProject / theodinproject

Main Website for The Odin Project
http://www.theodinproject.com
MIT License
3.59k stars 2.06k forks source link

Bug: Sortable project solutions stay on same page number when changing sort #4347

Open JustWaveThings opened 6 months ago

JustWaveThings commented 6 months ago

Checks

Bug description

When there is pagination in the project list, changing the sort by doesn't take the user to, for example, 'the most liked' projects. It applies the sort correctly but stays on the current page.

You can see I'm on page 2, and I've changed my sort to 'most liked', but I'm still on page 2, not seeing the most liked, which are on page 1. image

How to reproduce

  1. sign in.
  2. visit starting point
  3. change sort to 'most liked'
  4. observe that the URL updates to sort=likes_count but is still on page 2, not showing the most liked. after sort change

Expected behavior

  1. sign in
  2. visit starting point
  3. change sort to 'most liked'
  4. page shows the most liked on page 1

What browsers are you seeing the problem on?

Chrome

What OS are you using?

MacOS

Discord Name

Fred | Blog API

Additional Comments

I love the feature, and I'm making the assumption here that this is not the desired behavior. If it is, It's not a big lift to manually click the page number to navigate to.

KevinMulhern commented 6 months ago

Thanks @JustWaveThings, this is a great point!

I'm leaning towards always going back to the start when the sort is changed. I can see some benefit in maintaining your position in the list within the pagination. But going back to the start seems like it would be more useful with the sort options we make available.

I wouldn't mind getting some third and fourth opinions about it before going ahead though aha.

Extra

It won't be hard to do - we're handling the params for the sort here. If pagination has been used, the page param will be implicitly merged into the selected sort params and sent over the wire together. If we want the sort to always go back to the start, we can do that by explicitly overriding the page param with page: 1 as one of the params.

luuu-xu commented 6 months ago

@KevinMulhern I think it would make more sense to jump to page 1 whenever a sorting change is made by the user too. Because whenever users change the sorting rule, they are definitely expecting to view the data from page 1 again. (At least in my case!)

JustWaveThings commented 5 months ago

I am sorry I did't catch this when you were looking for people to review it.