How to bring back the missing filter order in the document pane in Sanity.io

8 replies
Last updated: Aug 3, 2021
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.
Aug 2, 2021, 7:40 PM
This is the missing filter order I mentioned from the document pane.
Aug 2, 2021, 7:43 PM
Hey User! What does your
deskStructure.js
look like?
Aug 2, 2021, 9:06 PM
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 
      
    ],

)
Aug 2, 2021, 9:14 PM
I'm assuming it might have to do with adding a method regarding the three dots. Thanks
Aug 2, 2021, 9:18 PM
I see! A
documentList
can take a
defaultOrdering
and a
getDefaultOrdering
method . Adding one of those might be the solution! If that doesn’t work, you could try converting it into a
documentTypeList
instead as that will include ordering by default.
Aug 2, 2021, 10:07 PM
Ah, thanks so much! I will check this out.
Aug 3, 2021, 8:39 AM
 .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'}]})
                    ])
                   ),
                  ]),   
Aug 3, 2021, 2:39 PM
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.
Aug 3, 2021, 2:42 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?