Skip to content

[bug]: "Cannot read properties of undefined (reading 'Root')" on Modal component #1777

Open
@mmarzullotv

Description

@mmarzullotv

What version of design-system are you using?

^1.19.0

What's Wrong?

When I try to add a Modal component, entire UI will crash in white with the error on the title. Is not recognizing the <Modal.Root>. I'm using this component inside a custom field plugin on Strapi's CMS.

I was also wondering where to add the <DesignSystemProvider> provider in this case since from the plugin perspective, it just loads a component. Should I just wrap the component in this provider either way? I tried but keeps happening the same issue.

Screenshot 2024-08-16 at 13 02 25

This is my current code that I was testing as an example:

const ModalImpl = (): JSX.Element => {
  return (
    <Modal.Root>
      <Modal.Trigger>
        <Button>Select Content</Button>
      </Modal.Trigger>
      <Modal.Content>
        <Modal.Header>
          <Modal.Title>Search content</Modal.Title>
        </Modal.Header>
        <Modal.Body>
          <Field.Root name="name" required>
            <Field.Label>Content Title</Field.Label>
            <Field.Input />
          </Field.Root>
        </Modal.Body>
        <Modal.Footer>
          <Modal.Close>
            <Button variant="tertiary">Cancel</Button>
          </Modal.Close>
          <Button>Confirm</Button>
        </Modal.Footer>
      </Modal.Content>
    </Modal.Root>
  );
};

This is my dependency list

"dependencies": {
    "@strapi/design-system": "^1.19.0",
    "@strapi/icons": "^1.19.0",
    "@strapi/plugin-cloud": "4.25.6",
    "@strapi/plugin-i18n": "4.25.6",
    "@strapi/plugin-users-permissions": "4.25.6",
    "@strapi/strapi": "4.25.6",
    "better-sqlite3": "8.6.0",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-router-dom": "5.3.4",
    "styled-components": "5.3.3"
  },

To Reproduce

Add a markdown for a <Modal.Root>

Expected Behaviour

It should render without any issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugIssue reporting a bugstatus: pending reproductionWaiting for free time to reproduce the issue, or more information

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions