react-component / tooltip

React Tooltip
http://react-component.github.io/tooltip/
MIT License
926 stars 189 forks source link

Closing when the user clicks in the scrollbar of the browser #86

Open doubleppereira opened 7 years ago

doubleppereira commented 7 years ago

Hi guys, We are usign rc-tooltip in our products but there is one small bug that is causing some problems and it's the following we click in a input text it shows the tooltip where the user can select an item and that item text would show in the input text. Very similar with the ryanair component to search for cities from and to -> https://www.ryanair.com/gb/en/. If the user clicks outside of the tooltip it closes as expected and it makes sense. But the problem happens when the user might have a small resolution and cannot see the entire tooltip we wants to scroll. This works fine using the mouse roller but if we has a touchpad needs to click in the scrollbar that makes the tooltip to close.

I wonder if there is anyway to bypass this. In the ryanair component it actually works like that. And that would be amazing to this with rc-tooltip.

benjycui commented 7 years ago

It seems that it is hard to tell whether we are clicking on scrollbar or not, for scrollbar is not part of DOM.

We can tell if we are click on the scrollbar of viewport by complicated calculation, but it's useless, for some divs can have scrollbar, too.

benjycui commented 7 years ago

Close now, for the ROI is extremely low.

If someone is interested in this issue, you can try to PR, we will merge it if the solution is good enough.

doubleppereira commented 7 years ago

I think it's a valid issue even if the ROI is extremely low. I just don't get why the ticket is being closed if there is no solution for this at the moment. If I have time I will try to do a PR.

doubleppereira commented 7 years ago

Hi, for what I saw in your rc-trigger lib is that in the method onDocumentClick we could put a function to check if event.clientX >= document.documentElement.offsetWidth then it would be sure it would be clicking on the scroll bar

doubleppereira commented 7 years ago

Created a PR in rc-trigger. https://github.com/react-component/trigger/pull/60#pullrequestreview-44267205