sanity-io / sanity

Sanity Studio – Rapidly configure content workspaces powered by structured content
https://www.sanity.io
MIT License
5.17k stars 417 forks source link

[Bug Report] Unable to move page modules after document is published #4744

Open rylanharper opened 1 year ago

rylanharper commented 1 year ago

Describe the bug

This issue has persisted since version 3.12.0 (and possibly earlier). Essentially, it affects any type of page builder with modules/sections (likely represented as type: 'array'?). Upon clicking the publish button, the modules become unmovable. For a visual demonstration of the bug, please refer to the video below.

To Reproduce

Create a sanity studio. I have a simple homePage schema with a project reference field:

homePage.js:

import { HouseLine } from '@phosphor-icons/react'

export default {
  title: 'Home',
  name: 'homePage',
  type: 'document',
  fields: [
    {
      title: 'Featured Projects',
      name: 'projects',
      type: 'array',
      of: [
        {
          type: 'reference',
          to: [{ type: 'project' }]
        }
      ]
    }
  ],
  preview: {
    prepare() {
      return {
        title: 'Home Page',
        media: HouseLine
      }
    }
  }
}

project.js (simplified for issue report):

import { File } from '@phosphor-icons/react'

export default {
  title: 'Project',
  name: 'project',
  type: 'document',
  icon: File,
  groups: [
    {
      title: 'Content',
      name: 'content',
      default: true
    },
    {
      title: 'SEO',
      name: 'seo'
    }
  ],
  fields: [
    {
      title: 'Title',
      name: 'title',
      type: 'string',
      description: 'Project title',
      group: 'content'
    },
    {
      title: 'URL Slug',
      name: 'slug',
      type: 'slug',
      description: '(required)',
      options: {
        source: 'title',
        maxLength: 96
      },
      validation: (rule) => rule.required(),
      group: 'content'
    },
    {
      title: 'Preview Image',
      name: 'previewImage',
      type: 'picture',
      description: 'This is the main image used to showcase the project',
      group: 'content'
    },
    {
      title: 'SEO',
      name: 'seo',
      type: 'seo',
      group: 'seo'
    }
  ],
  preview: {
    select: {
      title: 'title',
      media: 'previewImage.asset'
    },
    prepare({ title, subtitle, media }) {
      return {
        title: title ?? 'Untitled Project',
        media: media ?? File
      }
    }
  }
}

Next hit the publish button. You will notice when the document is published you can no longer move the modules..

Expected behavior

The modules should be able to move after I publish a document (in order to edit them further if desired).

Screenshots

https://github.com/sanity-io/sanity/assets/16216160/7956f08b-da2f-4a3f-b678-ebbead8e26dc

Which versions of Sanity are you using? ^3.14.4

parkerhutchinson commented 1 year ago

I can confirm that this is happening for me as well using the same version of sanity. refreshing the list is the only way to get the moveable functionality back.

rylanharper commented 1 year ago

Bumping this because this is still prevalent with the latest version..

torstah commented 10 months ago

Same here

rylanharper commented 8 months ago

Hey Sanity Team! This is still a major issue, would be great to get this marked with a bug flag or at least get noticed lol.