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

[BUG] onOutsideClick fires when dragging from inside #57

Open mtmacdonald opened 3 years ago

mtmacdonald commented 3 years ago

Describe the bug

When you click inside a popover, then drag the mouse outside the popover and release the mouse, then onOutsideClick fires (meaning the popover then closes in my case). We have popovers with forms where users click and drag while copying values. They reported it being annoying that the popover closes when they try to do this.

Not sure if this is a bug, the intended behaviour, or an unavoidable behaviour. We are aware that we can avoid onOutsideClick closing the popover in this situation, but would like to know if that's the best or only resolution.

To Reproduce

Steps to reproduce the behavior:

  1. Navigate to this story
  2. Open the popover
  3. Click mouse down over text
  4. Drag mouse to highlight text, but continue to drag outside the border of the popover
  5. Release mouse outside the popover
  6. Popover closes

Expected behavior

onOutsideClick fires and popover closes only when the click is initiated outside the layer, but doesn't close when mousedown is inside the layer but mouseup is outside the layer.

Screenshots

Browser / OS (please complete the following information):

Tested on Chrome and Firefox on OS X. We saw one small browser difference in our test story: in Chrome it's always reproducable. In Firefox, if you select text in the input and then drag mouse outside popover, in that case it doesn't close the popover in Firefox.

Additional context We are tracking this in ticket #92