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

Don't fatal with weird event.relatedTarget #4017

Merged
merged 1 commit into from
Jun 2, 2015
Merged
Show file tree
Hide file tree
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
22 changes: 18 additions & 4 deletions src/kibana/components/vislib/components/tooltip/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,36 @@ define(function (require) {
}
}

element
.on('mousemove.tip', function update() {
fakeD3Bind(this, 'mousemove', function () {
if (!self.showCondition.call(element, d, i)) {
return render();
}

var events = self.events ? self.events.eventResponse(d, i) : d;
return render(self.formatter(events));
})
.on('mouseleave.tip', function () {
});

fakeD3Bind(this, 'mouseleave', function () {
render();
});

});
};
};

function fakeD3Bind(el, event, handler) {
$(el).on(event, function (e) {
// mimicing https://github.com/mbostock/d3/blob/3abb00113662463e5c19eb87cd33f6d0ddc23bc0/src/selection/on.js#L87-L94
var o = d3.event; // Events can be reentrant (e.g., focus).
d3.event = e;
try {
handler.apply(this, [this.__data__]);
} finally {
d3.event = o;
}
});
}

return Tooltip;
};
});
5 changes: 0 additions & 5 deletions src/kibana/components/vislib/lib/dispatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ define(function (require) {
var $el = this.handler.el;

function hover(d, i) {
d3.event.stopPropagation();

// Add pointer if item is clickable
if (isClickable) {
self.addMousePointer.call(this, arguments);
Expand All @@ -131,8 +129,6 @@ define(function (require) {
var $el = this.handler.el;

function mouseout() {
d3.event.stopPropagation();

self.unHighlightLegend.call(this, $el);
}

Expand All @@ -149,7 +145,6 @@ define(function (require) {
var addEvent = this.addEvent;

function click(d, i) {
d3.event.stopPropagation();
self.emit('click', self.eventResponse(d, i));
}

Expand Down