Skip to content

Commit

Permalink
Destroy all old background layer tooltips before making new ones
Browse files Browse the repository at this point in the history
(closes #5551)
  • Loading branch information
bhousel committed Dec 5, 2018
1 parent 4bfc78c commit bee01d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions modules/ui/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export function uiBackground(context) {
var description = d.description();
var isOverflowing = (span.property('clientWidth') !== span.property('scrollWidth'));

item.call(tooltip().destroyAny);

if (d === _previousBackground) {
item.call(tooltip()
.placement(placement)
Expand All @@ -66,8 +68,6 @@ export function uiBackground(context) {
.placement(placement)
.title(description || d.name())
);
} else {
item.call(tooltip().destroy);
}
});
}
Expand Down
12 changes: 10 additions & 2 deletions modules/util/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,27 @@ export function tooltip() {
};


tooltip.destroy = function(selection) {
tooltip.destroy = function(selection, selector) {
// by default, just destroy the current tooltip
selector = selector || '.tooltip-' + _id;

selection
.on('mouseenter.tooltip', null)
.on('mouseleave.tooltip', null)
.attr('title', function() {
return this.getAttribute('data-original-title') || this.getAttribute('title');
})
.attr('data-original-title', null)
.selectAll('.tooltip-' + _id)
.selectAll(selector)
.remove();
};


tooltip.destroyAny = function(selection) {
selection.call(tooltip.destroy, '.tooltip');
};


function setup() {
var root = d3_select(this);
var animate = _animation.apply(this, arguments);
Expand Down

0 comments on commit bee01d8

Please sign in to comment.