Skip to content

Commit df351c3

Browse files
committed
Introduce _module.selectable flag for trace modules [1852]
- Reason: code for checking if a trace supports selection was duplicated across the code base.
1 parent d7087a6 commit df351c3

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

src/components/modebar/manage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function isSelectable(fullData) {
193193

194194
var trace = fullData[i];
195195

196-
if(!trace._module || !trace._module.getPointsIn || !trace._module.toggleSelected) continue;
196+
if(!trace._module || !trace._module.selectable) continue;
197197

198198
if(Registry.traceIs(trace, 'scatter-like')) {
199199
if(scatterSubTypes.hasMarkers(trace) || scatterSubTypes.hasText(trace)) {

src/plots/cartesian/select.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,7 @@ function determineSearchTraces(gd, xAxes, yAxes) {
462462
cd = gd.calcdata[i];
463463
trace = cd[0].trace;
464464

465-
if(trace.visible !== true || !trace._module ||
466-
!trace._module.toggleSelected || !trace._module.getPointsIn) continue;
465+
if(trace.visible !== true || !trace._module || !trace._module.selectable) continue;
467466

468467
// TODO is dragOptions.subplot is ever set? If not, delete.
469468
// if(dragOptions.subplot) {

src/plots/plots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac
11711171
traceOut.visible = !!traceOut.visible;
11721172
}
11731173

1174-
if(_module && _module.getPointsIn && _module.toggleSelected) {
1174+
if(_module && _module.selectable) {
11751175
coerce('selectedpoints');
11761176
}
11771177

src/registry.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ function registerTraceModule(_module) {
241241
exports.allCategories[categoriesIn[i]] = true;
242242
}
243243

244+
_module.selectable = _module.getPointsIn && _module.toggleSelected;
245+
244246
exports.modules[thisType] = {
245247
_module: _module,
246248
categories: categoryObj

0 commit comments

Comments
 (0)