Skip to content

Cannot read properties of undefined (reading 'onClick') on Popover and Menu #7591

@thomaslecoeur

Description

@thomaslecoeur

Dependencies check up

  • I have verified that I use latest version of all @mantine/* packages

What version of @mantine/* packages do you have in package.json?

7.17.2

What package has an issue?

@mantine/core

What framework do you use?

Next.js

In which browsers you can reproduce the issue?

Not applicable – issue is not related to the browser

Describe the bug

I get this error sometimes on Menu and Popover. I'm using Next.JS 15 and React 19. Error was not happening with Next.JS 14 and previous React version.

 ⨯ TypeError: Cannot read properties of undefined (reading 'onClick')
    at @mantine/core/MenuTarget (../../../../src/components/Menu/MenuTarget/MenuTarget.tsx:30:52)
  28 |   const _childrenProps = children.props as any;
  29 |
> 30 |   const onClick = createEventHandler(_childrenProps.onClick, () => {
     |                                                    ^
  31 |     if (ctx.trigger === 'click') {
  32 |       ctx.toggleDropdown();
  33 |     } else if (ctx.trigger === 'click-hover') { {
  digest: '3306055790'
}

Here is the JSX for this error :

<Menu shadow="md" width={200}>
  <MenuTarget>
    <ActionIcon size="lg" variant="transparent" aria-label="Settings">
      <IconDotsVertical size={16} stroke={1.5} />
    </ActionIcon>
  </MenuTarget>
  <MenuDropdown>
    <ABomDeleteArticleButton abom={node.abom} abomArticleId={node.articleId}>
      <MenuItem leftSection={<IconTrash size={16} />}>
        Supprimer l&apos;article
      </MenuItem>
    </ABomDeleteArticleButton>
  </MenuDropdown>
</Menu>

If possible, include a link to a codesandbox with a minimal reproduction

No response

Possible fix

No response

Self-service

  • I would be willing to implement a fix for this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions