Skip to content

Commit abbabe4

Browse files
authored
Merge pull request #5165 from plotly/fix5021-disable-text-selection
Disable text selection
2 parents 86f5e2d + aac45fa commit abbabe4

File tree

9 files changed

+19
-34
lines changed

9 files changed

+19
-34
lines changed

src/components/legend/draw.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ module.exports = function draw(gd, opts) {
8989
if(title.text) {
9090
var titleEl = Lib.ensureSingle(scrollBox, 'text', 'legendtitletext');
9191
titleEl.attr('text-anchor', 'start')
92-
.classed('user-select-none', true)
9392
.call(Drawing.font, title.font)
9493
.text(title.text);
9594

@@ -410,7 +409,6 @@ function drawTexts(g, gd, opts) {
410409
var textEl = Lib.ensureSingle(g, 'text', 'legendtext');
411410

412411
textEl.attr('text-anchor', 'start')
413-
.classed('user-select-none', true)
414412
.call(Drawing.font, opts.font)
415413
.text(isEditable ? ensureLength(name, maxNameLength) : name);
416414

src/components/rangeselector/draw.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ function drawButtonText(button, selectorLayout, d, gd) {
144144
}
145145

146146
var text = Lib.ensureSingle(button, 'text', 'selector-text', function(s) {
147-
s.classed('user-select-none', true)
148-
.attr('text-anchor', 'middle');
147+
s.attr('text-anchor', 'middle');
149148
});
150149

151150
text.call(Drawing.font, selectorLayout.font)

src/components/sliders/draw.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,10 @@ function drawCurrentValue(sliderGroup, sliderOpts, valueOverride) {
302302
}
303303

304304
var text = Lib.ensureSingle(sliderGroup, 'text', constants.labelClass, function(s) {
305-
s.classed('user-select-none', true)
306-
.attr({
307-
'text-anchor': textAnchor,
308-
'data-notex': 1
309-
});
305+
s.attr({
306+
'text-anchor': textAnchor,
307+
'data-notex': 1
308+
});
310309
});
311310

312311
var str = sliderOpts.currentvalue.prefix ? sliderOpts.currentvalue.prefix : '';
@@ -357,11 +356,10 @@ function drawGrip(sliderGroup, gd, sliderOpts) {
357356

358357
function drawLabel(item, data, sliderOpts) {
359358
var text = Lib.ensureSingle(item, 'text', constants.labelClass, function(s) {
360-
s.classed('user-select-none', true)
361-
.attr({
362-
'text-anchor': 'middle',
363-
'data-notex': 1
364-
});
359+
s.attr({
360+
'text-anchor': 'middle',
361+
'data-notex': 1
362+
});
365363
});
366364

367365
var tx = data.step.label;

src/components/updatemenus/draw.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ function drawHeader(gd, gHeader, gButton, scrollBox, menuOpts) {
195195

196196
// draw drop arrow at the right edge
197197
var arrow = Lib.ensureSingle(gHeader, 'text', constants.headerArrowClassName, function(s) {
198-
s.classed('user-select-none', true)
199-
.attr('text-anchor', 'end')
198+
s.attr('text-anchor', 'end')
200199
.call(Drawing.font, menuOpts.font)
201200
.text(constants.arrowSymbol[menuOpts.direction]);
202201
});
@@ -435,11 +434,10 @@ function drawItemRect(item, menuOpts) {
435434

436435
function drawItemText(item, menuOpts, itemOpts, gd) {
437436
var text = Lib.ensureSingle(item, 'text', constants.itemTextClassName, function(s) {
438-
s.classed('user-select-none', true)
439-
.attr({
440-
'text-anchor': 'start',
441-
'data-notex': 1
442-
});
437+
s.attr({
438+
'text-anchor': 'start',
439+
'data-notex': 1
440+
});
443441
});
444442

445443
var tx = itemOpts.label;

src/plot_api/plot_api.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3717,13 +3717,15 @@ function makePlotFramework(gd) {
37173717

37183718
// Plot container
37193719
fullLayout._container = gd3.selectAll('.plot-container').data([0]);
3720-
fullLayout._container.enter().insert('div', ':first-child')
3720+
fullLayout._container.enter()
3721+
.insert('div', ':first-child')
37213722
.classed('plot-container', true)
37223723
.classed('plotly', true);
37233724

37243725
// Make the svg container
37253726
fullLayout._paperdiv = fullLayout._container.selectAll('.svg-container').data([0]);
37263727
fullLayout._paperdiv.enter().append('div')
3728+
.classed('user-select-none', true)
37273729
.classed('svg-container', true)
37283730
.style('position', 'relative');
37293731

src/plots/gl2d/scene2d.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,6 @@ proto.makeFramework = function() {
145145

146146
this.updateSize(canvas);
147147

148-
// disabling user select on the canvas
149-
// sanitizes double-clicks interactions
150-
// ref: https://github.com/plotly/plotly.js/issues/744
151-
canvas.className += ' user-select-none';
152-
153148
// create SVG container for hover text
154149
var svgContainer = this.svgContainer = document.createElementNS(
155150
'http://www.w3.org/2000/svg',

src/traces/carpet/plot.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ function drawAxisTitle(gd, layer, trace, t, xy, dxy, axis, xa, ya, labelOrientat
239239
'rotate(' + orientation.angle + ') ' +
240240
'translate(0,' + offset + ')'
241241
)
242-
.classed('user-select-none', true)
243242
.attr('text-anchor', 'middle')
244243
.call(Drawing.font, axis.title.font);
245244
});

src/traces/parcoords/parcoords.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,7 @@ function styleExtentTexts(selection) {
350350
selection
351351
.classed(c.cn.axisExtentText, true)
352352
.attr('text-anchor', 'middle')
353-
.style('cursor', 'default')
354-
.style('user-select', 'none');
353+
.style('cursor', 'default');
355354
}
356355

357356
function parcoordsInteractionState() {
@@ -655,8 +654,7 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
655654

656655
axis.selectAll('text')
657656
.style('text-shadow', '1px 1px 1px #fff, -1px -1px 1px #fff, 1px -1px 1px #fff, -1px 1px 1px #fff')
658-
.style('cursor', 'default')
659-
.style('user-select', 'none');
657+
.style('cursor', 'default');
660658

661659
var axisHeading = axisOverlays.selectAll('.' + c.cn.axisHeading)
662660
.data(repeat, keyFun);
@@ -673,7 +671,6 @@ module.exports = function parcoords(gd, cdModule, layout, callbacks) {
673671
.classed(c.cn.axisTitle, true)
674672
.attr('text-anchor', 'middle')
675673
.style('cursor', 'ew-resize')
676-
.style('user-select', 'none')
677674
.style('pointer-events', 'auto');
678675

679676
axisTitle

src/traces/sankey/render.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,6 @@ module.exports = function(gd, svg, calcData, layout, callbacks) {
10261026
.append('text')
10271027
.classed(c.cn.nodeLabel, true)
10281028
.attr('transform', textFlip)
1029-
.style('user-select', 'none')
10301029
.style('cursor', 'default')
10311030
.style('fill', 'black');
10321031

0 commit comments

Comments
 (0)