fix: OHIF-307 - Click outside patient info should close tooltip (#1886)

This commit is contained in:
Rodrigo Antinarelli authored and GitHub committed 2020-07-22 21:07:20 +02:00
1 parent a6b7657840
commit afcd3f5263
5 files changed
+109 -90

No files matched your search

@@ -1,10 +0,0 @@
export default element => {
const handleClickOutside = event => {
if (element.current && !element.current.contains(event.target)) {
element.current.blur();
document.removeEventListener('mousedown', handleClickOutside);
}
};
document.addEventListener('mousedown', handleClickOutside);
};
@@ -0,0 +1,17 @@
export default (element, onClickOutside) => {
const clickOutsideHandler = event => {
if (element.current && !element.current.contains(event.target)) {
onClickOutside();
window.removeEventListener('mousedown', clickOutsideHandler);
}
};
const add = () => window.addEventListener('mousedown', clickOutsideHandler);
const remove = () =>
window.removeEventListener('mousedown', clickOutsideHandler);
return {
add,
remove,
};
};