diff --git a/src/plots/cartesian/select.js b/src/plots/cartesian/select.js index 70952c023dc..98afbcd5e84 100644 --- a/src/plots/cartesian/select.js +++ b/src/plots/cartesian/select.js @@ -74,7 +74,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) { for(i = 0; i < gd.calcdata.length; i++) { cd = gd.calcdata[i]; trace = cd[0].trace; - if(!trace._module || !trace._module.selectPoints) continue; + if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue; if(dragOptions.subplot) { if( diff --git a/src/traces/bar/select.js b/src/traces/bar/select.js index 309016c72be..37f434138dc 100644 --- a/src/traces/bar/select.js +++ b/src/traces/bar/select.js @@ -13,12 +13,9 @@ var DESELECTDIM = require('../../constants/interactions').DESELECTDIM; module.exports = function selectPoints(searchInfo, polygon) { var cd = searchInfo.cd; var selection = []; - var trace = cd[0].trace; var node3 = cd[0].node3; var i; - if(trace.visible !== true) return []; - if(polygon === false) { // clear selection for(i = 0; i < cd.length; i++) { diff --git a/src/traces/scatter/select.js b/src/traces/scatter/select.js index a529a4c21e6..96cd76fe2d8 100644 --- a/src/traces/scatter/select.js +++ b/src/traces/scatter/select.js @@ -26,7 +26,7 @@ module.exports = function selectPoints(searchInfo, polygon) { // TODO: include lines? that would require per-segment line properties var hasOnlyLines = (!subtypes.hasMarkers(trace) && !subtypes.hasText(trace)); - if(trace.visible !== true || hasOnlyLines) return []; + if(hasOnlyLines) return []; var opacity = Array.isArray(marker.opacity) ? 1 : marker.opacity; diff --git a/src/traces/scattergeo/select.js b/src/traces/scattergeo/select.js index 8cdfc187ef7..aeacd646423 100644 --- a/src/traces/scattergeo/select.js +++ b/src/traces/scattergeo/select.js @@ -22,7 +22,7 @@ module.exports = function selectPoints(searchInfo, polygon) { var di, lonlat, x, y, i; var hasOnlyLines = (!subtypes.hasMarkers(trace) && !subtypes.hasText(trace)); - if(trace.visible !== true || hasOnlyLines) return []; + if(hasOnlyLines) return []; var marker = trace.marker; var opacity = Array.isArray(marker.opacity) ? 1 : marker.opacity; diff --git a/src/traces/scattergl/select.js b/src/traces/scattergl/select.js index e4187fb9eda..498a99ba287 100644 --- a/src/traces/scattergl/select.js +++ b/src/traces/scattergl/select.js @@ -26,7 +26,7 @@ module.exports = function selectPoints(searchInfo, polygon) { var scene = glTrace.scene; var hasOnlyLines = (!subtypes.hasMarkers(trace) && !subtypes.hasText(trace)); - if(trace.visible !== true || hasOnlyLines) return []; + if(hasOnlyLines) return []; // filter out points by visible scatter ones if(polygon === false) { diff --git a/src/traces/scattermapbox/select.js b/src/traces/scattermapbox/select.js index 7e464ae17fd..35eaf523e9a 100644 --- a/src/traces/scattermapbox/select.js +++ b/src/traces/scattermapbox/select.js @@ -24,7 +24,7 @@ module.exports = function selectPoints(searchInfo, polygon) { // to not insert data-driven 'circle-opacity' when we don't need to trace._hasDimmedPts = false; - if(trace.visible !== true || !subtypes.hasMarkers(trace)) return []; + if(!subtypes.hasMarkers(trace)) return []; if(polygon === false) { for(i = 0; i < cd.length; i++) { diff --git a/test/jasmine/tests/select_test.js b/test/jasmine/tests/select_test.js index 00301826243..6affd0b3741 100644 --- a/test/jasmine/tests/select_test.js +++ b/test/jasmine/tests/select_test.js @@ -687,6 +687,12 @@ describe('Test select box and lasso per trace:', function() { fig.layout.dragmode = 'select'; fig.layout.geo.scope = 'europe'; + // add a trace with no locations which will then make trace invisible, lacking DOM elements + fig.data.push(Lib.extendDeep({}, fig.data[0])); + fig.data[1].text = []; + fig.data[1].locations = []; + fig.data[1].z = []; + Plotly.plot(gd, fig) .then(function() { return _run(