Skip to content

Crash when using validation #29

@frederikgdl

Description

@frederikgdl

When using validation for a field with type colorlist and the validation fails there is a warning icon next to the field label in the studio. When hovering over the icon the studio crashes with the error Error: flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering.

This can be recreated by creating a new studio with for instance the blog template. Then add the example field from the readme and add validation.

{
    title: "Color List",
    description: "Pick a color",
    name: "colors",
    type: "colorlist",
    options: {
      list: [
        { title: "Red", value: "#f16d70" },
        { title: "Teal", value: "#88c6db" },
        { title: "Purple", value: "#aca0cc" },
        { title: "Green", value: "#bdcdcb" },
        { title: "White", value: "white" },
      ],
    },
    validation: (Rule) => Rule.required(),
  },

When creating a document the warning icon appears, when hovering over the icon the studio crashes.

I'm using the following versions:

@sanity/cli                   2.35.0 (up to date)
@sanity/base                  2.35.0 (up to date)
@sanity/core                  2.35.0 (up to date)
@sanity/default-layout        2.35.0 (up to date)
@sanity/default-login         2.35.0 (up to date)
@sanity/desk-tool             2.35.1 (up to date)
@sanity/eslint-config-studio   2.0.1 (up to date)
@sanity/vision                2.35.0 (up to date)

Node and npm

v16.17.0
8.19.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions