product list and inventory list default order#14911
product list and inventory list default order#14911majianbing wants to merge 1 commit intomedusajs:developfrom
Conversation
|
|
Someone is attempting to deploy a commit to the medusajs Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| queryFn: async () => | ||
| sdk.admin.inventoryItem.retrieve(id, { | ||
| fields: INVENTORY_DETAIL_FIELDS, | ||
| order: "-created_at", |
There was a problem hiding this comment.
Order parameter added to detail query instead of list
Medium Severity
The order: "-created_at" parameter is added to inventoryDetailQuery, which calls sdk.admin.inventoryItem.retrieve(id, ...) — a single-item retrieval endpoint. Ordering is meaningless when fetching one item by ID. The PR intends to change the default sort order of the inventory list, but the inventory list table (in inventory-list-table.tsx) is untouched. This change has no user-visible effect and the actual intended inventory list ordering fix is missing.
| limit: 20, | ||
| offset: 0, | ||
| is_giftcard: false, | ||
| order: "-created_at", |
There was a problem hiding this comment.
Loader query key mismatches component query key causing flicker
Medium Severity
The loader now pre-fetches with order: "-created_at", but the actual product list table component (product-list-table.tsx) calls useProducts with query params from useProductTableQuery, which defaults order to undefined when there's no URL parameter. This creates a query key mismatch: the loader caches under a key containing order: "-created_at", while the component queries under a different key without order. The loader's initialData (sorted descending) briefly displays, then gets replaced by a background refetch using the default ascending order — resulting in a visible flicker and the intended sort order not persisting.
|
Thank you for your contribution! After reviewing this PR, we need a few things addressed before we can move forward: Required changes:
Potential Bugs:
queryKey: productsQueryKeys.list({ limit: 20, offset: 0, is_giftcard: false }),
queryFn: async () =>
sdk.admin.product.list({ limit: 20, offset: 0, is_giftcard: false, order: "-created_at" }),If |


Summary
What — What changes are introduced in this PR?
In the dashboard, the product list and inventory list default order is ascending. But users care more about the most recent added items.
Why — Why are these changes relevant or necessary?
Yes, I think so. users care more about the most recent added items.
How — How have these changes been implemented?
simply use order -xxx
Testing — How have these changes been tested, or how can the reviewer test the feature?
yes
Examples
Provide examples or code snippets that demonstrate how this feature works, or how it can be used in practice.
This helps with documentation and ensures maintainers can quickly understand and verify the change.
Checklist
Please ensure the following before requesting a review:
yarn changesetand follow the promptsAdditional Context
Add any additional context, related issues, or references that might help the reviewer understand this PR.
Note
Low Risk
Low risk UI data-fetch parameter change; main impact is that list/detail fetches will return items in a different default order.
Overview
Updates dashboard data loaders to request newest-first ordering by adding
order: "-created_at"to the inventory item retrieve call and the products list query, so recently created items appear first by default.Written by Cursor Bugbot for commit 1d52299. This will update automatically on new commits. Configure here.