Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu component prop onClose not called when MenuItem nested inside MenuSection #546

Closed
oanylund opened this issue Sep 8, 2020 · 1 comment · Fixed by #592
Closed

Menu component prop onClose not called when MenuItem nested inside MenuSection #546

oanylund opened this issue Sep 8, 2020 · 1 comment · Fixed by #592
Assignees
Labels
🐛 bug Something isn't working core-react eds-core-react

Comments

@oanylund
Copy link

oanylund commented Sep 8, 2020

Describe the bug

When a MenuItem is nested inside a MenuSection the Menu components prop onClose is not called when MenuItem fires onClick event.

Steps to reproduce the bug

it('has called onClose when MenuItem is clicked', () => {
    const handleOnClose = jest.fn()
    const handleOnClick = jest.fn()

    render(
      <Menu open onClose={handleOnClose}>
        <MenuSection title="test">
          <MenuItem onClick={handleOnClick}>Item 1</MenuItem>
        </MenuSection>
      </Menu>,
    )

    const menuItem = screen.getByText('Item 1')

    fireEvent.click(menuItem)

    expect(handleOnClick).toHaveBeenCalled()
    expect(handleOnClose).toHaveBeenCalled()
})

Expected behavior

Expect handleOnClose to have been called, but it's not.

Specifications

  • Version: equinor/eds-core-react v0.6.0
  • Browser: Chrome 85.0.4183.83
  • OS: Windows 10
@oanylund oanylund added the 🐛 bug Something isn't working label Sep 8, 2020
@mimarz mimarz self-assigned this Sep 8, 2020
@mimarz
Copy link
Contributor

mimarz commented Sep 8, 2020

Thanks for reporting!

You even added a test for us to use 🤩

@mimarz mimarz added the core-react eds-core-react label Sep 9, 2020
@pomfrida pomfrida assigned pomfrida and unassigned mimarz Sep 10, 2020
@pomfrida pomfrida linked a pull request Sep 10, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working core-react eds-core-react
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants