Category links should honor category order settings

AI-generated summary

The issue concerns category links on the homepage/sidebar not honoring the category’s default sorting order. Nacho_Caballero reported that clicking a category link uses /latest.json, sorting topics by latest activity instead of the configured order (e.g., ‘Created Descending’). While reloading the page applies the correct order, the initial load does not. JammyDodger confirmed the bug and noted a fix was in progress. david later pushed a second fix, and Nacho_Caballero confirmed the issue was resolved after the update.

Continuing the discussion from Sorting by creation date doesn't work:

The category/tag links on the homepage/sidebar (class=“subcategory”) load the category using /latest.json. It doesn’t appear on the URL, but you can see it in the Network tab:

This means that the topics in the category will be sorted by latest activity.

If the category has a setting with a different order, it is not honored.
To see the default order, you have to reload the page. Example: category 25 with order “created descending”:

3 Likes

Just to confirm that we’ve been able to replicate this and we’re looking into it. :+1:

2 Likes

I think this is fixed now in: :+1:

https://github.com/discourse/discourse/pull/23270

4 Likes

@JammyDodger @david I just upgraded and the issue is still there. To reproduce:

  1. Set a category’s default order to “Created Descending”
  2. Click on that category’s link on the homepage/sidebar

Expected behavior: topics sorted by descending created date.
Actual behavior: topics sorted by descending modified date.

  1. Reload the page

Expected behavior: topics remain sorted by descending modified date.
Actual behavior: topics are now correctly sorted by descending created date.

1 Like

Hi @Nacho_Caballero - I just pushed a second fix which should get things working as expected:

https://github.com/discourse/discourse/commit/534f62cf5b6796f9e5380aaf9fd7721d75ac096e

Please let us know if you’re still seeing any problems after updating.

5 Likes

Thanks for the great work, David. Now it works perfectly. :ok_hand:

4 Likes

This topic was automatically closed after 5 days. New replies are no longer allowed.