Direct link to show group members in descending order not working

AI-generated summary

A bug was reported regarding the inability to create a direct link showing group members in descending order. sygou explained that while the backend accepts order and asc parameters (where a blank asc implies descending), the frontend defaults asc to true. When a user attempts to force descending order via a URL like ?order=added_at&asc=, the frontend incorrectly converts this to asc=false. Since the backend logic treats any non-blank string (including “false”) as a request for ascending order, the link fails, displaying members in ascending order despite showing a descending sort icon. sygou suggested the frontend should convert the boolean false to an empty string in the URL parameter. awesomerobot confirmed that the issue has been resolved by a recent change to honor the asc query string parameter on group sorting. Jesse_Starks expressed gratitude for the fix.

  • For listing members in a group, the backend code accepts order and asc parameters to order by a specific field in ascending/descending order. When the asc parameter is present and non-blank, it is the ascending order, otherwise descending.
  • The frontend code of the group members page also seems to be able to parse query parameters and pass to the backend. asc is true by default on the frontend.

When I navigate to this link: https://try.discourse.org/g/trust_level_2?order=added_at&asc=, I expect this to be a direct link to show me TL2 members ordered by Added time in descending order, without having to manually click on the table header to toggle ordering.

However the actual behavior is that: it shows TL2 members ordered by Added time in ascending order, yet with a “chevron-down” icon (suggesting that it should have shown in descending order instead):

Looking at the Network tab in DevTools, the page issued a request of https://try.discourse.org/groups/trust_level_2/members.json?offset=0&order=added_at&asc=false&filter=, instead of https://try.discourse.org/groups/trust_level_2/members.json?offset=0&order=added_at&asc=&filter=.

As all URL parameters are strings, asc=false will be considered as non-blank by the params[:asc] && params[:asc].present? logic, thus returning ascending result. Perhaps the frontend code should convert the Boolean false value of asc to an empty string in the URL parameter?

2 Likes

Thanks for checking this, asc=false will work as of the change here

2 Likes

Hey that’s awesome… you rock! Thanks!

2 Likes