sanity: Pasting into an empty block text area throws `Cannot apply deep operations on primitive value`

Describe the bug

Pasting into an empty block text area throws the following error:

Error: Cannot apply deep operations on primitive values. Received patch with type "unset" and path "{"_key":"acf5fd264449"} that targeted the value "undefined"
    at _primitiveApply (http://localhost:3333/node_modules/.sanity/vite/deps/chunk-ZX3U2FOT.js?v=9f7159b1:144105:11)
    at _applyPatch (http://localhost:3333/node_modules/.sanity/vite/deps/chunk-ZX3U2FOT.js?v=9f7159b1:144144:10)
    at applyPatch5 (http://localhost:3333/node_modules/.sanity/vite/deps/chunk-ZX3U2FOT.js?v=9f7159b1:144147:15)
    at Array.reduce (<anonymous>)
    at applyAll2 (http://localhost:3333/node_modules/.sanity/vite/deps/chunk-ZX3U2FOT.js?v=9f7159b1:144132:18)
    at http://localhost:3333/node_modules/.sanity/vite/deps/chunk-ZX3U2FOT.js?v=9f7159b1:144175:22
    at http://localhost:3333/node_modules/.sanity/vite/deps/chunk-ZX3U2FOT.js?v=9f7159b1:152229:9
    at http://localhost:3333/node_modules/.sanity/vite/deps/chunk-ZX3U2FOT.js?v=9f7159b1:114111:7
    at http://localhost:3333/node_modules/.sanity/vite/deps/chunk-ZX3U2FOT.js?v=9f7159b1:114123:7
    at safelyCallDestroy (http://localhost:3333/node_modules/.sanity/vite/deps/chunk-ZX3U2FOT.js?v=9f7159b1:23469:13)

To Reproduce

Steps to reproduce the behavior:

  1. Create a schema which has an array field of block types. eg:
{
      name: 'text',
      title: 'Text',
      type: 'array',
      of: [
        {
          type: 'block',
        },
      ],
    },
  1. Try and paste (CMD+v) into the empty text editor.

Expected behavior

The copied text is pasted.

Which versions of Sanity are you using?

3.7.1

What operating system are you using?

macOs Monterey 12.3

Which versions of Node.js / npm are you running?

8.19.2 v18.12.1

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 17
  • Comments: 17 (3 by maintainers)

Most upvoted comments

We are looking into this. Thank you for reporting!

Thanks for the fix in 3.8.0 @skogsmaskin and the rest of the team

Oh, just noticed I forgot to update this issue (we have a couple of duplicates on this).

Yes this is now fixed. Closing this! Thank you for reporting and sorry about the inconvenience.

Hey all, obviously annoying as a workaround, but you can type something into the field then paste and it works.