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

[popover2] onClose is triggered twice in controlled mode #4607

Closed
glentakahashi opened this issue Mar 26, 2021 · 2 comments
Closed

[popover2] onClose is triggered twice in controlled mode #4607

glentakahashi opened this issue Mar 26, 2021 · 2 comments

Comments

@glentakahashi
Copy link

Environment

  • Package version(s): popover2@0.3.2
  • Operating System: Big sur 11.2.3
  • Browser name and version: Chrome 89.0.4389.90

Code Sandbox

Minimal repro: https://codesandbox.io/s/onclose-duplicate-bug-lwvrh

Steps to reproduce

  1. Use Popover2 in controlled state
  2. Add onClose function
  3. Open popover
  4. Click outside of popover

Actual behavior

onClose is called twice: once for the mouse event, once without an evt (when isOpen is flagged to false)

Expected behavior

onClose is only called for the mouseEvent, and no onClose is called for when isOpen is changed

Possible solution

@adidahiya
Copy link
Contributor

What are you using onClose for in controlled mode? Is onInteraction not sufficient? Note that this is also a "bug" for Popover, so it's not a regression: https://codesandbox.io/s/onclose-duplicate-bug-forked-rgyd9

@glentakahashi
Copy link
Author

Ah good call, I didn't realized onInteraction would be the better hook to use here. This is fine to close out then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants