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

DropdownToggle with children does not close when toggle is clicked #2660

Closed
FoodProduct opened this issue Dec 6, 2022 · 2 comments
Closed

Comments

@FoodProduct
Copy link

  • components: DropdownToggle
  • reactstrap version #9.1.5
  • import method es
  • react version #18.2.0, #16.14.0
  • bootstrap version #5.2.3

What is happening?

Clicking a <DropdownToggle> with non-string children on an open Dropdown triggers toggle() twice, which prevents the dropdown from closing.

What should be happening?

Clicking the dropdown toggle should close the dropdown.

Steps to reproduce issue

https://github.com/FoodProduct/bootstrap-dropdown-component

  1. Have a <DropdownToggle> whose children are not a simple string (e.g.<div>Click me</div>)
  2. Open the dropdown
  3. Click the dropdown toggle

Error message in console

N/A

Code

https://stackblitz.com/edit/reactstrap-vcxbgg?file=Example.js

This is because the document click event handler does not recognize the click event on the toggle properly, causing an extra trigger, i.e. the following check fails:

const targetIsToggle = e.target === toggle;

illiteratewriter added a commit to illiteratewriter/reactstrap that referenced this issue Dec 20, 2022
- fix issue where if children of dropdown toggle where not simple
strings the dropdown would remain open
@rabarrota
Copy link

Any update on this?

@FoodProduct
Copy link
Author

Any update on this?

@illiteratewriter graciously opened a PR with the fix in December, but unfortunately it does not seem to have been reviewed yet 😞

illiteratewriter added a commit that referenced this issue Mar 2, 2023
* fix(#2660): dropdown closes for complex children

- fix issue where if children of dropdown toggle where not simple
strings the dropdown would remain open

* test: add test for Dropdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants