Repository navigation
feat(media): add sort by title (A to Z / Z to A) - #2016
Conversation
🦋 Changeset detectedLatest commit: fe37f9c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@trostum is attempting to deploy a commit to the Sanity Sandbox Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
🟡 Changes recommended
Localized title objects require locale-aware sorting logic before approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds title-based sorting to the media library dropdown, including ascending and descending options.
Changes:
- Adds title sort labels and options.
- Adds a minor changeset documenting the feature.
- Requires locale-aware handling for localized titles.
File summaries
| File | Summary |
|---|---|
plugins/sanity-plugin-media/src/constants.ts |
Adds title sort options. |
plugins/sanity-plugin-media/src/config/orders.ts |
Adds title sort labels. |
.changeset/media-sort-by-title.md |
Documents the release. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
9b92caf to
db77acb
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit db77acb. Configure here.
Head branch was pushed to by a user without write access
d8fc3bc to
d0acd18
Compare
Adds a new sort option group to the media library dropdown, alongside the existing file name sort options. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The sort reducer that runs after uploads, edits and listener updates compared the raw localized title object, so every pair compared as equal. Resolve the value through the configured locales, matching the GROQ coalesce() order. Also add localeIds to the folder epic test fixtures added on main.
d0acd18 to
fe37f9c
Compare
Head branch was pushed to by a user without write access
|
Thank you so much @trostum |
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## sanity-plugin-media@6.6.0 ### Minor Changes - [#2016](#2016) [`c7408b1`](c7408b1) Thanks [@trostum](https://github.com/trostum)! - Add "Title: A to Z" and "Title: Z to A" sort options to the sort order dropdown. When `locales` are configured, title sorting coalesces through the configured locales in declared order. ## sanity-plugin-shopify-assets@2.1.0 ### Minor Changes - [#2062](#2062) [`2c565d0`](2c565d0) Thanks [@pedrobonamin](https://github.com/pedrobonamin)! - Add an optional `dataset` setting on the plugin and on `shopify.asset` fields so asset requests can use the dataset connected to Shopify. A field value overrides the plugin value, and `dataset` and `shopifyDomain` can be overridden independently. When neither is set, requests keep using the active Studio dataset. ## sanity-naive-html-serializer@5.1.16 ### Patch Changes - [#2083](#2083) [`9b7e239`](9b7e239) Thanks [@pedrobonamin](https://github.com/pedrobonamin)! - Preserve span mark definitions, including links without an href, when converting portable text to HTML and back. An edited anchor href in the HTML replaces the stored link URL. ## sanity-plugin-internationalized-array@5.3.8 ### Patch Changes - [#2063](#2063) [`8c7098b`](8c7098b) Thanks [@pedrobonamin](https://github.com/pedrobonamin)! - Field options such as `accept` on an internationalized array field are passed through to each language's underlying value field. ## sanity-plugin-studio-smartling@5.0.23 ### Patch Changes - Updated dependencies []: - sanity-translations-tab@6.1.26 ## sanity-plugin-transifex@5.1.26 ### Patch Changes - Updated dependencies []: - sanity-translations-tab@6.1.26 ## sanity-translations-tab@6.1.26 ### Patch Changes - Updated dependencies [[`9b7e239`](9b7e239)]: - sanity-naive-html-serializer@5.1.16 ## @sanity/document-internationalization@6.2.45 No changes in this release. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Version and changelog-only release automation with no runtime code changes in this PR; risk is limited to routine npm publish coordination. > > **Overview** > This is an automated **Changesets** release PR: it bumps npm versions, appends **CHANGELOG** entries, and removes the consumed `.changeset` files. There is **no application source diff** here—only packaging metadata for publishing already-merged work. > > **What ships in this release:** `sanity-plugin-media@6.6.0` adds title A→Z / Z→A sorting (locale-aware when `locales` are set). `sanity-plugin-shopify-assets@2.1.0` adds optional `dataset` on the plugin and `shopify.asset` fields. `sanity-naive-html-serializer@5.1.16` improves portable text ↔ HTML round-trips for span marks and links. `sanity-plugin-internationalized-array@5.3.8` forwards field options (e.g. `accept`) to per-language value fields. `sanity-translations-tab`, Smartling, and Transifex pick up the serializer bump; `@sanity/document-internationalization@6.2.45` is a version-only release with no listed changes. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 47d4ac1. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: squiggler-app[bot] <265501495+squiggler-app[bot]@users.noreply.github.com>

Description
Adds a "Title" sort group to the media library's sort order dropdown ("Title: A to Z" / "Title: Z to A"), alongside the existing "File name: A to Z" / "Z to A" options. Assets can already be given a
title via the existing "Title" search facet field; there was previously no way to sort by it — only by file name, MIME type, size, and created/updated timestamps.
Implementation is a straight extension of the existing sort-option mechanism:
src/config/orders.ts— added thetitleentry toORDER_DICTIONARYwith the two direction labelssrc/constants.ts— added thetitleasc/desc entries toORDER_OPTIONS, in their own divider-separated group after "File name"No changes to the query/dispatch logic — the field is interpolated straight into the existing
order(field direction)GROQ query, same asoriginalFilename,mimeType, andsizealready are.What to review
src/config/orders.tsandsrc/constants.tsfor the newtitleentriesOrderSelect) in the media browser — pick "Title: A to Z" / "Z to A" and confirm assets reorder by theirtitlefieldTesting
No dedicated unit tests were added, matching the existing convention: the other sort options (
originalFilename,mimeType,size, timestamps) have no test coverage of their own either —getOrderTitle/ORDER_OPTIONSaren't exercised by a test file in this package today.Verified instead by:
pnpm lintandpnpm format --checkon the changed filespnpm turbo build --filter=sanity-plugin-mediavitestsuite for the package (258 tests passing, unaffected)Note
Low Risk
Additive sorting and query expression changes for title only; localized coalesce is covered by unit tests and mirrors documented fallback behavior.
Overview
Adds Title: A to Z and Title: Z to A to the media library sort dropdown (new group in
ORDER_OPTIONSand labels inorders.ts).When the plugin
localesoption is set, title sorting no longer orders on the rawtitleobject: GROQorder()uses acoalesce()across configured locale keys (in array order), and in-store re-sorts use matchinggetOrderValuelogic so server and client stay aligned.localeIdsare passed from tool options throughReduxProviderinto the assets slice; fetch paging builds sort withgetOrderField. README documents localized title sort behavior;orders.test.tscovers labels, GROQ field building, and value resolution.Reviewed by Cursor Bugbot for commit d0acd18. Bugbot is set up for automated code reviews on this repo. Configure here.