Which plugin is affected?
@sanity/orderable-document-list
Describe the bug
The orderRankField defines an async initialValue that fetches the last
rank and assigns the next one. However, this initialValue is not applied in
certain document creation flows, resulting in documents missing the orderRank field
entirely.
Affected scenarios:
- Documents that existed before the plugin was installed
- Documents published without fully opening the edit form first
- Documents created programmatically or via import
- Documents created via the Sanity HTTP API or MCP tools (e.g. AI assistants using Sanity's MCP server), since
initialValue is a Studio-only concept and is never invoked in those flows. In this case, the user is required to manually press "Reset Order" in the Studio after the document is created to assign a rank.
To reproduce
- Add
orderRankField({ type: 'yourType' }) to a schema
- Create a document without opening the full edit form (e.g. via the "Create
new" button in the orderable list but publish immediately)
- Observe the document is saved without an
orderRank value
- The document appears out of order or breaks the orderable list
Expected behavior
initialValue should be applied on every new document creation flow, ensuring orderRank is always set before the first save.
Environment
- Sanity Studio version: 3.x
- Plugin version: 1.5.1
- Browser: Chrome
- Operating system: macOS
Additional context
As a workaround, we added a custom document action that detects when orderRankis missing and patches both the draft and published document client-side usingthe Sanity client.
Which plugin is affected?
@sanity/orderable-document-list
Describe the bug
The
orderRankFielddefines an asyncinitialValuethat fetches the lastrank and assigns the next one. However, this
initialValueis not applied incertain document creation flows, resulting in documents missing the
orderRankfieldentirely.
Affected scenarios:
initialValueis a Studio-only concept and is never invoked in those flows. In this case, the user is required to manually press "Reset Order" in the Studio after the document is created to assign a rank.To reproduce
orderRankField({ type: 'yourType' })to a schemanew" button in the orderable list but publish immediately)
orderRankvalueExpected behavior
initialValueshould be applied on every new document creation flow, ensuringorderRankis always set before the first save.Environment
Additional context
As a workaround, we added a custom document action that detects when
orderRankis missing and patches both the draft and published document client-side usingthe Sanity client.