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

toggleMenu not working with react-dom 17 #608

Closed
alex84G opened this issue Dec 7, 2020 · 5 comments
Closed

toggleMenu not working with react-dom 17 #608

alex84G opened this issue Dec 7, 2020 · 5 comments
Labels

Comments

@alex84G
Copy link

alex84G commented Dec 7, 2020

Version

5.1.2

Steps to reproduce

In want to fire the toggleMenu() method from a button.
There is an example of how to fire the public methods: https://ericgio.github.io/react-bootstrap-typeahead/#public-methods
But the toggleMenu() method is not working. In this stackoverflow answer someone mentioned, that the public methods are not listed in the type definitions.

Sandbox: https://codesandbox.io/s/purple-sunset-dhikf?fontsize=14&hidenavigation=1&theme=dark

Expected Behavior

toggleMenu() should open the dropdown.

Actual Behavior

toggleMenu() is not fired.

@alex84G alex84G added the bug label Dec 7, 2020
@ericgio
Copy link
Owner

ericgio commented Dec 7, 2020

Hi @alex84G, thanks for your question. Unfortunately, it's hard for me to help without additional information. Please follow the issue template and include a thorough description of your problem. Code examples or sandboxes are extremely helpful as well. Thank you!

@alex84G
Copy link
Author

alex84G commented Dec 8, 2020

Hi @alex84G, thanks for your question. Unfortunately, it's hard for me to help without additional information. Please follow the issue template and include a thorough description of your problem. Code examples or sandboxes are extremely helpful as well. Thank you!

Hi @ericgio, I've updated my issue and added a sandbox.

@ericgio
Copy link
Owner

ericgio commented Dec 8, 2020

@alex84G: Thanks for providing the sandbox. The problem appears to be related to react-dom v17. Downgrading the version to 16.x solves the issue. Using react v17 doesn't seem to be a problem. I'll need to look into why this is happening.

Edit: It looks like the event handling has changed such that the RootClose component gets called after toggleMenu, so the menu opens and closes immediately.

@ericgio
Copy link
Owner

ericgio commented Dec 9, 2020

As a workaround, you can stop the event propagation in your click handler:

<button
  onClick={(event) => {
    event.stopPropagation();
    ref.current.toggleMenu();
  }}>
  Open
</button>

@ericgio ericgio changed the title toggleMenu() not fired toggleMenu not working with react-dom 17 Dec 9, 2020
@ericgio
Copy link
Owner

ericgio commented Dec 9, 2020

Turns out this was related to an issue with react-overlays. Upgrading to the latest version seems to have solved the problem.

@ericgio ericgio closed this as completed Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants