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

UserMenu Avatar onClick overrides the open behavior #307

Closed
joebochill opened this issue Jul 22, 2021 · 0 comments · Fixed by #310
Closed

UserMenu Avatar onClick overrides the open behavior #307

joebochill opened this issue Jul 22, 2021 · 0 comments · Fixed by #310
Assignees
Labels
brightlayer-ui Used to identify Brightlayer UI platform issues for easy filtering bug Something not working as expected good first issue A good issue for first-time contributors high-priority Issues that should be fixed sooner than later user-menu Affects User-Menu Component

Comments

@joebochill
Copy link
Collaborator

Describe the bug

If you put a onClick event on the Avatar that is passed into a UserMenu, that prop overrides the onClick behavior that is set up to open the menu.

What is the expected behavior?

The user-supplied onClick should be merged with the internal click handler

What are the steps to reproduce?

  1. Add a UserMenu to a project
  2. Add a onClick prop to the Avatar, e.g., <Avatar onClick={() => console.log('clicked')}>AB</Avatar>
  3. Click the avatar
  4. Observe that the menu is not opened and only the user-supplied click callback is executed

Anything else to add?

This is caused because we spread the user supplied Avatar props after defining the onClick prop (https://github.com/pxblue/react-component-library/blob/dev/components/src/core/UserMenu/UserMenu.tsx#L140). This causes the user-supplied onClick prop to overwrite what we set on the line above. The spread should come before the onClick.

@joebochill joebochill added bug Something not working as expected user-menu Affects User-Menu Component needs-review Issues that we would like to revisit/review good first issue A good issue for first-time contributors labels Jul 22, 2021
@emclaug2 emclaug2 added high-priority Issues that should be fixed sooner than later and removed needs-review Issues that we would like to revisit/review labels Aug 4, 2021
@joebochill joebochill added the brightlayer-ui Used to identify Brightlayer UI platform issues for easy filtering label Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
brightlayer-ui Used to identify Brightlayer UI platform issues for easy filtering bug Something not working as expected good first issue A good issue for first-time contributors high-priority Issues that should be fixed sooner than later user-menu Affects User-Menu Component
Development

Successfully merging a pull request may close this issue.

3 participants