How to bring back the missing filter order in the document pane in Sanity.io
8 replies
Last updated: Aug 3, 2021
M
Hi all. I've built a bespoke structure builder and the ordering at the top of the pane (the three dots to be able to filter) has gone but only comes back if I use S.documentTypeListItems() and I tried to find a way of bringing it back. So now I'm trying to create a new list item to filter using GROQ for example 'client by name' etc but I don't know how to query a document list or even where. Do I add something in the filter method for example by name ascending or descending as well as the date? I'm really stuck and help would be appreciated.
M
This is the missing filter order I mentioned from the document pane.
M
import S from "@sanity/desk-tool/structure-builder";
import { createSuperPane } from 'sanity-super-pane';
//import {FiSettings } from "react-icons/fi";
export default () => S.list()
.title('Cube Content')
.items(
[
S.listItem()
.title('Clients')
.child(
S.list()
.title('Clients')
.items([
S.listItem()
.title('Create Project')
.child(
S.documentList()
.title('project')
.schemaType('project')
.filter('_type == "project"')
),
S.listItem()
.title('Client Footer')
.child(
S.document()
.schemaType('clientFooter')
.documentId('clientFooter')
),
])
),
// ...S.documentTypeListItems() not using
],
)M
I'm assuming it might have to do with adding a method regarding the three dots. Thanks
I see! A
documentListcan take a
defaultOrderingand a
getDefaultOrderingmethod . Adding one of those might be the solution! If that doesn’t work, you could try converting it into a
documentTypeListinstead as that will include ordering by default.
M
Ah, thanks so much! I will check this out.
M
.child(
S.documentList()
.title('Projects')
.schemaType('project')
.filter('_type == "project"')
.menuItems([
...S.documentTypeList('project').getMenuItems(),
S.orderingMenuItem({title: 'Project Title ascending', by: [{field: 'theFieldName', direction: 'asc'}]}),
S.orderingMenuItem({title: 'Project Title descending', by: [{field: 'theFieldName', direction: 'desc'}]})
])
),
]), M
If anyone else is wondering how to solve this I used the menuItem([...]) as you can see above. You can also swap out the ordering in the MenuItems([...]) for the normal document ordering property.
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.