sanity-io / sanity

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

[desk-tool] Removing type definition from a block-array crashes the desking tool #916

Closed saasen closed 4 years ago

saasen commented 6 years ago

Versions

@sanity/cli             0.132.5 (up to date)
@sanity/base            0.132.5 (up to date)
@sanity/components      0.132.5 (up to date)
@sanity/core            0.132.5 (up to date)
@sanity/default-layout  0.132.5 (up to date)
@sanity/default-login   0.132.5 (up to date)
@sanity/desk-tool       0.132.5 (up to date)

Details

Operating system: Windows 10 Node.js: v10.1.0 NPM: 5.6.0

Stack trace

TypeError: Cannot read property 'jsonType' of undefined
    at Object.FormBuilderContext.resolveInputComponent.type (http://localhost:3333/static/js/app.bundle.js:61087:90)
    at Object.memoizedMap [as resolveInputComponent] (http://localhost:3333/static/js/app.bundle.js:61056:24)
    at FormBuilderInput.resolveInputComponent (http://localhost:3333/static/js/app.bundle.js:14645:37)
    at FormBuilderInput.render (http://localhost:3333/static/js/app.bundle.js:14688:33)
    at finishClassComponent (http://localhost:3333/static/js/vendor.bundle.js:18829:31)
    at updateClassComponent (http://localhost:3333/static/js/vendor.bundle.js:18791:10)
    at beginWork (http://localhost:3333/static/js/vendor.bundle.js:19460:14)
    at performUnitOfWork (http://localhost:3333/static/js/vendor.bundle.js:21499:12)
    at workLoop (http://localhost:3333/static/js/vendor.bundle.js:21538:24)
    at renderRoot (http://localhost:3333/static/js/vendor.bundle.js:21578:7)
Component stack:
    in FormBuilderInput (created by SimpleFocusManager)
    in div (created by SimpleFocusManager)
    in SimpleFocusManager (created by FormBuilderBlock)
    in div (created by DialogContent)
    in DialogContent (created by FormBuilderBlock)
    in div (created by Stacked)
    in div (created by Stacked)
    in div (created by CaptureOutsideClicks)
    in CaptureOutsideClicks (created by Stacked)
    in div (created by Stacked)
    in div (created by Stacked)
    in Stacked (created by DefaultDialog)
    in Portal (created by DefaultDialog)
    in DefaultDialog (created by FormBuilderBlock)
    in div (created by StopPropagation)
    in StopPropagation (created by FormBuilderBlock)
    in div (created by FormBuilderBlock)
    in FormBuilderBlock (created by BlockNode)
    in BlockNode (created by Node)
    in div (created by Void)
    in div (created by Void)
    in Void (created by Node)
    in Node (created by Content)
    in div (created by Content)
    in Content (created by Editor)
    in Editor (created by BlockEditor)
    in div (created by BlockEditor)
    in div (created by BlockEditor)
    in div (created by ActivateOnFocus)
    in div (created by ActivateOnFocus)
    in ActivateOnFocus (created by WrappedActivateOnFocus)
    in WrappedActivateOnFocus (created by BlockEditor)
    in div (created by BlockEditor)
    in div (created by DefaultFormField)
    in label (created by DefaultFormField)
    in div (created by DefaultFormField)
    in DefaultFormField (created by BlockEditor)
    in BlockEditor (created by Syncer)
    in div (created by Syncer)
    in Syncer (created by withPatches(Syncer))
    in withPatches(Syncer) (created by FormBuilderInput)
    in div (created by FormBuilderInput)
    in FormBuilderInput (created by Field)
    in div (created by Field)
    in Field (created by ObjectInput)
    in div (created by ObjectInput)
    in ObjectInput (created by FormBuilderInput)
    in div (created by FormBuilderInput)
    in FormBuilderInput (created by SanityFormBuilder)
    in FormBuilderContext (created by SanityFormBuilderContext)
    in SanityFormBuilderContext (created by SanityFormBuilder)
    in SanityFormBuilder (created by Editor)
    in form (created by Editor)
    in div (created by Editor)
    in div (created by ScrollContainer)
    in ScrollContainer (created by Pane)
    in div (created by Pane)
    in div (created by Pane)
    in Pane (created by Styleable(Pane))
    in Styleable(Pane) (created by Editor)
    in Editor (created by withRouter(Editor))
    in withRouter(Editor) (created by EditorWrapper)
    in EditorWrapper (created by SchemaPaneResolver)
    in SplitPaneWrapper (created by SchemaPaneResolver)
    in div (created by PanesSplitController)
    in div (created by Pane)
    in Pane (created by SplitPane)
    in div (created by SplitPane)
    in SplitPane (created by PanesSplitController)
    in div (created by PanesSplitController)
    in div (created by Pane)
    in Pane (created by SplitPane)
    in div (created by SplitPane)
    in SplitPane (created by PanesSplitController)
    in div (created by PanesSplitController)
    in div (created by Pane)
    in Pane (created by SplitPane)
    in div (created by SplitPane)
    in SplitPane (created by PanesSplitController)
    in div (created by PanesSplitController)
    in div (created by PanesSplitController)
    in PanesSplitController (created by SchemaPaneResolver)
    in div (created by SchemaPaneResolver)
    in SchemaPaneResolver (created by DeskTool)
    in div (created by DeskTool)
    in DeskTool (created by withRouter(DeskTool))
    in withRouter(DeskTool) (created by RenderTool)
    in RenderTool (created by SchemaErrorReporter)
    in RouteScope (created by SchemaErrorReporter)
    in div (created by SchemaErrorReporter)
    in div (created by SchemaErrorReporter)
    in div (created by SchemaErrorReporter)
    in SchemaErrorReporter (created by DefaultLayout)
    in DefaultLayout (created by withRouter(DefaultLayout))
    in withRouter(DefaultLayout) (created by DefaultLayoutContainer)
    in RouterProvider (created by DefaultLayoutContainer)
    in LoginWrapper (created by DefaultLayoutContainer)
    in DefaultLayoutContainer (created by SanityRoot)
    in div (created by SanityRoot)
    in SanityRoot
    in AppContainer

Issue

Let's say you have this document:

export default {
    title: 'Movie',
    name: 'movie',
    type: 'document',
    fields: [
        [...] // ommitted for clarity
        {
            title: 'Content',
            name: 'content',
            type: 'array',
            of: [
                { type: 'block' },
                { type: 'collapsible }
            ]
        }
    ]
}

and this object:

export default {
    title: 'Collapsible',
    name: 'collapsible',
    type: 'object',
    fields: [
        {
            title: 'Title',
            name: 'title',
            type: 'string'
        }
    ]
}

When inside the desk-tool, it's now possible to insert instances of the type collapsible inside the array-of-block field. After you insert one or more and then delete the collapsible object definition from the project and try to click on anything made by that block in the block-editor, the desk-tool will crash.

A workaround for this issue is to click some text and pressing delete on the keyboard to remove the object instance. It's only interacting with it with the mouse that's causing it to crash.

bjoerge commented 6 years ago

Hi @saasen, thanks for reporting (and sorry for the radio silence!). We are aware of this and working on a fix.