Skip to content

Commit c2158a1

Browse files
committed
clear the clicktoshow pointer cursor after hovering off the clicked element
1 parent f7c197a commit c2158a1

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎src/components/dragelement/unhover.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
'use strict';
22

3+
var d3 = require('@plotly/d3');
4+
35
var Events = require('../../lib/events');
6+
var overrideCursor = require('../../lib/override_cursor');
47
var throttle = require('../../lib/throttle');
58
var getGraphDiv = require('../../lib/dom').getGraphDiv;
69

@@ -45,6 +48,8 @@ unhover.raw = function raw(gd, evt) {
4548
var oldhoverdata = gd._hoverdata;
4649

4750
if(!evt) evt = {};
51+
if(evt.target && evt.target.tagName) overrideCursor(d3.select(evt.target), '');
52+
4853
if(evt.target && !gd._dragged &&
4954
Events.triggerHandler(gd, 'plotly_beforehover', evt) === false) {
5055
return false;

‎test/jasmine/tests/hover_test.js‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4663,6 +4663,31 @@ describe('hover updates', function () {
46634663
}
46644664
}
46654665

4666+
it('should clear the clicktoshow pointer cursor on unhover', function (done) {
4667+
var gd = createGraphDiv();
4668+
var hasPointer = function () {
4669+
return d3Select(gd).select('.nsewdrag').node().classList.contains('cursor-pointer');
4670+
};
4671+
4672+
Plotly.newPlot(gd, [{ x: [0.5], y: [0.5] }], {
4673+
hovermode: 'closest',
4674+
margin: { t: 0, r: 0, b: 0, l: 0 },
4675+
width: 200,
4676+
height: 200,
4677+
xaxis: { range: [0, 1] },
4678+
yaxis: { range: [0, 1] },
4679+
annotations: [{ x: 0.5, y: 0.5, text: 'shown on click', visible: false, clicktoshow: 'onoff' }]
4680+
})
4681+
.then(function () {
4682+
mouseEvent('mousemove', 100, 100);
4683+
expect(hasPointer()).toBe(true, 'while over the point');
4684+
4685+
mouseEvent('mouseout', 100, 100);
4686+
expect(hasPointer()).toBe(false, 'after the mouse leaves the point');
4687+
})
4688+
.then(done, done.fail);
4689+
});
4690+
46664691
it('should update the labels on animation', function (done) {
46674692
var mock = {
46684693
data: [

0 commit comments

Comments
 (0)