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

If I use Dropddown or ComboBox in TableToolbarMenu, the popup menu will be closed upon selecting an option #6412

Closed
3 tasks done
akmalmzamri opened this issue Jul 8, 2020 · 5 comments · Fixed by amalgamaco/carbon#14 or #7456
Assignees
Labels

Comments

@akmalmzamri
Copy link
Contributor

If I use Dropddown or ComboBox in TableToolbarMenu, the popup menu will be closed upon selecting an option

What package(s) are you using?

  • @carbon/icons-react - 10.13.0
  • carbon-components - 10.15.0
  • carbon-components-react - 7.15.0

Detailed description

Describe in detail the issue you're having.

Basically whenever I select an option in Dropdown or Combobox, the TableToolbarMenu popup will be closed. This behavior is not seen with Select

What did you expect to happen? What happened instead? What would you like to
see changed?

I expect the behavior to be the same with Select

What browser are you working in?

Chrome

What version of the Carbon Design System are you using?

10.15.0

Please create a reduced test case in CodeSandbox

@tw15egan
Copy link
Collaborator

tw15egan commented Jul 8, 2020

Must have something to do with the click handler, using the keyboard to make a selection doesn't cause the menu to close 🤔

@tw15egan tw15egan added component: data-table impact: low package: react carbon-components-react role: dev 🤖 severity: 3 https://ibm.biz/carbon-severity labels Jul 8, 2020
@akmalmzamri
Copy link
Contributor Author

@tw15egan Is there any way for me to override the click handler?

@akmalmzamri
Copy link
Contributor Author

Any estimation on when will this issue be fixed?

@tanoargie
Copy link

Any update on this?

@tanoargie
Copy link

tanoargie commented Dec 14, 2020

handleClickOutside = (evt) => {
    if (
      this.state.open &&
      (!this._menuBody || !this._menuBody.contains(evt.target))
    ) {
      this.closeMenu();
    }
  };

The issue seems to be related to the OverflowMenu component. It has a click listener that is triggered if the user clicks outside the overflow menu (the handleClickOutside method in OverflowMenu.js). When clicking in the combobox/dropdown list, it checks if the list is contained in the menuBody (as it is rendered when clicking the combobox, not when opening the menu) and therefore closes the menu. I think the proper solution would be to bind the combobox/dropdown lists to the menuBody when opened or check if menuBody contains some parent. I made a quick workaround that checks if target is a list with the className but I think a more thorough fix should be implemented.
I hope this helps the team to find a solution!

@emyarod emyarod self-assigned this Dec 14, 2020
tanoargie added a commit to amalgamaco/carbon that referenced this issue Dec 16, 2020
…closing_when_combobox_item_is_clicked

Close carbon-design-system#6412 - Prevent overflowmenu closing when combox item is clicked.
@kodiakhq kodiakhq bot closed this as completed in #7456 Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants