From a479faf75ff811ab9694841c8dfe5df2c165e9c0 Mon Sep 17 00:00:00 2001 From: Marco van Meegen Date: Thu, 18 Jun 2020 13:04:45 +0200 Subject: [PATCH 1/3] #535 in bodyMode srach parents of current target for tooltips --- src/decorators/bodyMode.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/decorators/bodyMode.js b/src/decorators/bodyMode.js index 73001229b..cc08a56e3 100644 --- a/src/decorators/bodyMode.js +++ b/src/decorators/bodyMode.js @@ -19,10 +19,21 @@ const bodyListener = function(callback, options, e) { const { respectEffect = false, customEvent = false } = options; const { id } = this.props; - const tip = e.target.getAttribute("data-tip") || null; - const forId = e.target.getAttribute("data-for") || null; + let tip = null + let forId + let target = e.target + let lastTarget + // walk up parent chain until tip is found + // there is no match if parent visible area is matched by mouse position, so some corner cases might not work as expected + while (tip === null && target !== null) { + lastTarget = target + tip = target.getAttribute('data-tip') || null + forId = target.getAttribute('data-for') || null + target = target.parentElement + } + + target = lastTarget || e.target - const target = e.target; if (this.isCustomEvent(target) && !customEvent) { return; } From 65a1aad8e1d16e945fbd3e81d498f511af082bb9 Mon Sep 17 00:00:00 2001 From: Marco van Meegen Date: Thu, 18 Jun 2020 13:06:11 +0200 Subject: [PATCH 2/3] #535 in bodyMode srach parents of current target for tooltips: formatting --- src/decorators/bodyMode.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/decorators/bodyMode.js b/src/decorators/bodyMode.js index cc08a56e3..ba6a29218 100644 --- a/src/decorators/bodyMode.js +++ b/src/decorators/bodyMode.js @@ -19,20 +19,20 @@ const bodyListener = function(callback, options, e) { const { respectEffect = false, customEvent = false } = options; const { id } = this.props; - let tip = null - let forId - let target = e.target - let lastTarget + let tip = null; + let forId; + let target = e.target; + let lastTarget; // walk up parent chain until tip is found // there is no match if parent visible area is matched by mouse position, so some corner cases might not work as expected while (tip === null && target !== null) { - lastTarget = target - tip = target.getAttribute('data-tip') || null - forId = target.getAttribute('data-for') || null - target = target.parentElement + lastTarget = target; + tip = target.getAttribute('data-tip') || null; + forId = target.getAttribute('data-for') || null; + target = target.parentElement; } - target = lastTarget || e.target + target = lastTarget || e.target; if (this.isCustomEvent(target) && !customEvent) { return; From ba04bc637dab0f1d1df5a828ccdd91a665af4741 Mon Sep 17 00:00:00 2001 From: Marco van Meegen Date: Thu, 18 Jun 2020 17:37:57 +0200 Subject: [PATCH 3/3] feat(bodymode): bodymode: search parent chain of target for data-tip BREAKING CHANGE: if a tooltip applies to a dom tree instead of a single element, a click on tree's children will now result displaying a tooltip if a data-tip attribute is found in parent chain of clicked dom element. This might affect code where children are not contained in the bounds of their parents #535 --- src/decorators/bodyMode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/decorators/bodyMode.js b/src/decorators/bodyMode.js index ba6a29218..70299565d 100644 --- a/src/decorators/bodyMode.js +++ b/src/decorators/bodyMode.js @@ -27,8 +27,8 @@ const bodyListener = function(callback, options, e) { // there is no match if parent visible area is matched by mouse position, so some corner cases might not work as expected while (tip === null && target !== null) { lastTarget = target; - tip = target.getAttribute('data-tip') || null; - forId = target.getAttribute('data-for') || null; + tip = target.getAttribute("data-tip") || null; + forId = target.getAttribute("data-for") || null; target = target.parentElement; }