Have you ever spent hours crafting the perfect content in Sanity Studio, only to discover that your carefully structured numbered lists are continuing from previous counts instead of resetting to 1
? This frustrating bug has been plaguing content editors working with Sanity's Portable Text Editor, creating headaches for both content creators and developers alike.
When you create a new numbered list after paragraphs or headers, you rightfully expect the list to start from 1
. However, in affected versions of Sanity, the list stubbornly continues from wherever the previous list left off — turning what should be a "Step 1" into "Step 3" or "Step 8" without your permission.
This issue doesn't just affect how content looks in the editor; it carries through to your published content, creating confusion for readers and requiring extra work for content teams to manually correct the numbering.
Good news: Sanity officially fixed this bug in version 3.53.0 with a note in their release documentation stating they "Fixed an issue that could cause wrong list counts in the Portable Text Editor."
By the end of this tutorial, you'll be able to:
Before we begin, make sure you have:
The numbered list reset bug manifests when content editors create multiple numbered lists separated by other content elements like paragraphs, headings, or images. Instead of each new list starting with "1," the numbering continues from the previous list — creating a frustrating experience for both editors and readers.
In Sanity's Portable Text Editor (the rich text editing component), lists are handled as special block elements. When functioning properly, a new list block should reset its counter whenever it's preceded by a non-list block. However, in affected versions, the list counter state persists across blocks, creating this unexpected behavior.
Here's what the problem looks like in practice:
Notice how after the paragraph, the second list starts with 3
instead of 1
— a clear indication that the list counter isn't resetting as it should.
This issue affects the Portable Text's underlying data structure and subsequently impacts how content renders on the frontend. For content teams working on tutorials, step-by-step guides, or any structured content, this bug requires constant manual intervention or complex workarounds.
The definitive solution to this problem is upgrading to Sanity version 3.53.0 or higher, which contains an official fix for the numbered list bug. This version introduced a correction to how the Portable Text Editor manages list state between blocks, ensuring that new lists properly reset their counters.
While there are temporary workarounds (which we'll cover later), upgrading provides the most sustainable solution for several reasons:
The upgrade process involves updating your Sanity dependencies in your project's package.json file and running the appropriate package manager commands. In most cases, this is a straightforward process that takes less than an hour to complete.
Let's walk through the process of upgrading your Sanity installation to fix the numbered list bug.
Before making any changes, verify your current Sanity version to understand the scope of the upgrade.
Open your terminal, navigate to your Sanity Studio project directory, and run:
npx sanity --version
Alternatively, you can check the version in your package.json
file:
grep "sanity" package.json
Make note of your current version. If you're already on version 3.53.0 or higher, you should already have the fix in place (though you'll still want to verify this).
Now, update the Sanity dependencies in your package.json file. You can do this manually or using npm/yarn commands.
Open your package.json
file and update all Sanity-related dependencies to at least version 3.53.0:
Before:
{ "dependencies": { "@sanity/client": "^3.4.1", "@sanity/image-url": "^1.0.2", "sanity": "^3.23.4", "sanity-plugin-media": "^2.0.5", // Other dependencies... }}
After:
{ "dependencies": { "@sanity/client": "^3.4.1", "@sanity/image-url": "^1.0.2", "sanity": "^3.53.0", "sanity-plugin-media": "^2.0.5", // Other dependencies... }}
Alternatively, use npm or yarn to update all Sanity packages:
For npm:
npm update sanity @sanity/client @sanity/image-url
For yarn:
yarn upgrade sanity @sanity/client @sanity/image-url
ContentWrap helps companies save thousands on their Sanity bills through smart caching strategies and optimized API usage.
After updating your package.json, install the updated dependencies:
For npm:
npm install
For yarn:
yarn install
This may take a few minutes as it downloads and installs the updated packages.
Consult the Sanity release notes to see if there are any breaking changes between your previous version and 3.53.0 that might affect your project.
If you're making a significant version jump (e.g., from 3.20.x to 3.53.x), you'll want to pay special attention to any major changes that might require updates to your schemas or configuration.
Once the installation is complete, start your development server to ensure everything is working correctly:
npm run dev# oryarn dev
If you encounter any errors during startup, consult the error messages for guidance on resolving them. The most common issues relate to plugin compatibility or configuration changes.
After verifying that everything works correctly in your development environment, deploy the updated Sanity Studio:
sanity deploy
This will make the updated Studio available to all your content editors.
Now that you've upgraded, let's verify that the numbered list bug is actually fixed.
If the fix is working correctly, the second list should start with "1" instead of continuing from the previous list:
For a more thorough test:
If all tests pass, congratulations! The numbered list bug has been fixed in your Sanity Studio installation.
Despite the straightforward upgrade process, you might encounter some issues. Here's how to address the most common problems:
Problem: You've upgraded to Sanity 3.53.0+, but lists still don't reset properly.
Solution:
Problem: The npm/yarn upgrade command fails with dependency conflicts.
Solution:
# For npmnpm install --force# For yarnyarn install --force
If this doesn't resolve the issue, try removing your node_modules directory and reinstalling:
rm -rf node_modulesnpm install# oryarn install
Problem: After upgrading, your Sanity Studio fails to start with errors.
Solution: Check the error messages carefully. The most common issues are:
If you can't resolve the errors, consider a gradual upgrade approach by updating to intermediate versions first.
Problem: After the upgrade, previously created content displays incorrectly.
Solution: This is rare but can happen if the underlying data structure has changed. You may need to:
Contact Sanity support if you encounter persistent issues with existing content.
Problem: Custom Portable Text components no longer work correctly.
Solution: Review any custom components against the latest Sanity documentation. You may need to update your component code to match changes in the Sanity API.
The list numbering fix typically doesn't require changes to your existing content's data structure. However, it's worth understanding how the upgrade affects your content ecosystem.
In most cases, no manual updates are needed for existing content. The fix primarily affects how the Portable Text Editor handles new lists and renders existing ones, not the underlying data structure.
However, if you've implemented workarounds for the list numbering issue (like custom rendering components), you may need to remove these workarounds to avoid conflicts with the official fix.
If your site relies heavily on numbered lists, consider performing a content audit:
If you're using custom rendering for Portable Text on your frontend, ensure your rendering logic aligns with the fixed behavior. In particular, check any code that handles list rendering and numbering.
To minimize the impact of similar issues in the future:
Implement a regular update schedule for your Sanity installation:
Create a simple testing protocol for your content editors to follow after each upgrade:
Encourage content editors to report issues immediately:
Consider implementing a more formal version management strategy:
// Example package.json with pinned versions{ "dependencies": { "sanity": "3.53.0", "@sanity/client": "3.4.1", // Other dependencies... }}
Using exact versions (without ^ or ~) gives you more control over when updates occur, allowing for planned upgrade cycles.
The numbered list reset bug in Sanity CMS has been a significant pain point for content editors, but with the release of version 3.53.0, this issue has been officially resolved. By following the upgrade process outlined in this guide, you can provide your content team with a smoother, more intuitive editing experience.
Key takeaways from this guide:
Remember that maintaining your CMS is an ongoing process. Staying current with updates not only fixes bugs like this one but also provides your team with the latest features and security improvements.
Have you encountered other Sanity Studio issues that need addressing? Share your experiences in the comments below!
Eliminate timezone headaches in Sanity CMS with the rich-date-input plugin. Learn how to prevent publishing date confusion and ensure consistent datetime display for global teams with this simple yet powerful solution.
In this tutorial, you will learn how to extend Sanity CMS with custom superscript and subscript decorators for block array fields.
Discover why stegaClean is crucial for Sanity CMS projects. Learn how to identify and eliminate hidden characters that break your string comparisons, conditional logic, and component rendering.