Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#535 search parents of click target in body mode #613

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/decorators/bodyMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down