Skip to content

Commit 71da348

Browse files
author
vanmeegen
committed
feat(parent_body_mode): #535 search parents for data-tip if in body mode
1 parent 2a36416 commit 71da348

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/decorators/bodyMode.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,21 @@ const bodyListener = function(callback, options, e) {
1919
const { respectEffect = false, customEvent = false } = options;
2020
const { id } = this.props;
2121

22-
const tip = e.target.getAttribute('data-tip') || null;
23-
const forId = e.target.getAttribute('data-for') || null;
22+
let tip = null;
23+
let forId;
24+
let target = e.target;
25+
let lastTarget;
26+
// walk up parent chain until tip is found
27+
// there is no match if parent visible area is matched by mouse position, so some corner cases might not work as expected
28+
while (tip === null && target !== null) {
29+
lastTarget = target;
30+
tip = target.getAttribute('data-tip') || null;
31+
forId = target.getAttribute('data-for') || null;
32+
target = target.parentElement;
33+
}
34+
35+
target = lastTarget || e.target;
2436

25-
const target = e.target;
2637
if (this.isCustomEvent(target) && !customEvent) {
2738
return;
2839
}

0 commit comments

Comments
 (0)