Add filter option to @sanity/orderable-document-list
Good news! The Sanity team has already added the filter option to the @sanity/orderable-document-list plugin. Based on the GitHub repository, this feature is now available and documented.
You can add a filter parameter when configuring the orderable document list in your Desk Structure. Here's how to use it:
orderableDocumentListDeskItem({
type: 'project',
title: 'Projects',
// Add your filter here
filter: `__i18n_lang == $lang`,
params: {
lang: 'en_US',
},
S,
context,
})The filter works with GROQ query syntax and accepts parameters through the params option. This is particularly useful for scenarios like:
- Filtering by language in internationalized content
- Showing only published/draft documents
- Filtering by categories or tags
- Any other GROQ-compatible filter condition
Important caveat to be aware of: While the filter controls which documents are displayed in the list, the order ranks are still computed based on all documents of that type. As noted in the README:
However, order ranks are still computed based on all documents of the same
type. Creating multiple lists with differentfiltersettings could produce unexpected results.
So if you create multiple orderable lists with different filters for the same document type, you might see unexpected ordering behavior since they're all sharing the same orderRank field values.
The feature is available in the current version of the plugin, so make sure you're running an up-to-date version to access this functionality. You can check the releases page for version history.
Show original thread11 replies
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.