From 35a55e1401b08f1017390dd9c6d3bbe1a19cfdc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Thu, 21 Feb 2019 17:43:40 -0500 Subject: [PATCH] clear selection outline during 'axrange' relayout calls --- src/plot_api/plot_api.js | 7 +++++++ test/jasmine/tests/select_test.js | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index af89ecd81b2..c8e440b32fc 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -32,6 +32,7 @@ var connectColorbar = require('../components/colorbar/connect'); var initInteractions = require('../plots/cartesian/graph_interact').initInteractions; var xmlnsNamespaces = require('../constants/xmlns_namespaces'); var svgTextUtils = require('../lib/svg_text_utils'); +var clearSelect = require('../plots/cartesian/select').clearSelect; var dfltConfig = require('./plot_config').dfltConfig; var manageArrays = require('./manage_arrays'); @@ -2001,7 +2002,13 @@ function addAxRangeSequence(seq, rangesAltered) { return Axes.draw(gd, 'redraw'); }; + var _clearSelect = function(gd) { + var zoomlayer = gd._fullLayout._zoomlayer; + if(zoomlayer) clearSelect(zoomlayer); + }; + seq.push( + _clearSelect, subroutines.doAutoRangeAndConstraints, drawAxes, subroutines.drawData, diff --git a/test/jasmine/tests/select_test.js b/test/jasmine/tests/select_test.js index 3f165f7cfc7..7128933bd84 100644 --- a/test/jasmine/tests/select_test.js +++ b/test/jasmine/tests/select_test.js @@ -1226,6 +1226,28 @@ describe('Test select box and lasso in general:', function() { .then(done); }); + it('@flaky should have their selection outlines cleared during *axrange* relayout calls', function(done) { + var gd = createGraphDiv(); + var fig = Lib.extendDeep({}, mock); + fig.layout.dragmode = 'select'; + + function _drag() { + resetEvents(gd); + drag(selectPath); + return selectedPromise; + } + + Plotly.plot(gd, fig) + .then(_drag) + .then(function() { assertSelectionNodes(0, 2, 'after drag 1'); }) + .then(function() { return Plotly.relayout(gd, 'xaxis.range', [-5, 5]); }) + .then(function() { assertSelectionNodes(0, 0, 'after axrange relayout'); }) + .then(_drag) + .then(function() { assertSelectionNodes(0, 2, 'after drag 2'); }) + .catch(failTest) + .then(done); + }); + it('@flaky should select the right data with the corresponding select direction', function(done) { var gd = createGraphDiv();