calebjacob / tooltipster

A jQuery tooltip plugin
MIT License
2.76k stars 480 forks source link

Closing tooltip on click outside body #728

Open tdeniau-sticky opened 6 years ago

tdeniau-sticky commented 6 years ago

Currently only clicks on elements other than the tooltip inside the body are closing it.

I have a page where I display the tooltip at the bottom of the page and instinctively everybody clicks on the bottom, outside the body to close it and nothing happens.

The code responsible for this behavior seems to be the following:

$body.on(eventNames, function(event) {

        if (self._touchIsMeaningfulEvent(event)) {

            self._touchRecordEvent(event);

            if (!self.__options.interactive || !$.contains(self._$tooltip[0], event.target)) {
                self._close(event);
            }
        }
    });

Could you please handle clicks outside document body ?

louisameline commented 6 years ago

Hi, right, we're using the body element to catch events, using document could do the trick.