everweij / react-laag

Hooks to build things like tooltips, dropdown menu's and popovers in React
https://www.react-laag.com
MIT License
907 stars 47 forks source link

Click seen as outside click when layer’s content changes #18

Closed rijk closed 4 years ago

rijk commented 4 years ago

Hi Erik, me again ;) I ran into an issue while creating a menu with submenus. See this codesandbox: https://codesandbox.io/s/react-laag-sub-menus-k3kfn

  1. Open the menu
  2. Click "Visibility"
  3. Note that the menu closes, and the console prints "close via outside click"

Expected behaviour: menu doesn’t close.

rijk commented 4 years ago

Issue is not super pressing by the way, in the end I used a Transition to delay exit during the submenu animation, so the problem went away. But if it's an easy fix, would be nice to fix.

everweij commented 4 years ago

Hi Rijk, good to see you again :) Recently someone has reported a similar issue (#15). I forked your sandbox and upgraded react-laag from 1.3 to 1.5.1 (latest), and that seems to solve your issue. Problem was that the event-listener (closeOnOutsideClick) was a bit late too the party whenever the layer's content changed, so now closeOnOutsideClick listens in the 'capture' phase, so it's early too the party ;) Please let me know if there's anything else!

rijk commented 4 years ago

🙈