Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable text selection #5165

Merged
merged 7 commits into from
Sep 25, 2020
Merged

Disable text selection #5165

merged 7 commits into from
Sep 25, 2020

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Sep 25, 2020

Fixes #5021.

@plotly/plotly_js

@archmoj archmoj added bug something broken status: reviewable labels Sep 25, 2020
@alexcjohnson
Copy link
Collaborator

@nicolaskruchten mentioned leaving annotations and scatter text selectable, but ATM these elements already can't be selected normally, due to the way we capture pointer events.

That in mind, would it cause any problems to just put user-select: none at the top level and drop it everywhere else?

Note that ATM we specifically prevent selection on several specific elements, though a few of them (sankey and parcoords) use the simple version without vendor prefixes, which should be fixed if we don't switch to the top level.

 ~/plotly/plotly.js/src> ag user-select
traces/sankey/render.js
1029:        .style('user-select', 'none')

traces/parcoords/parcoords.js
354:        .style('user-select', 'none');
659:        .style('user-select', 'none');
676:        .style('user-select', 'none')

traces/carpet/plot.js
242:            .classed('user-select-none', true)

css/_base.scss
26:.user-select-none {
27:    @include vendor('user-select', none);

components/legend/draw.js
92:            .classed('user-select-none', true)
413:        .classed('user-select-none', true)

components/updatemenus/draw.js
198:        s.classed('user-select-none', true)
438:        s.classed('user-select-none', true)

components/rangeselector/draw.js
147:        s.classed('user-select-none', true)

components/sliders/draw.js
305:        s.classed('user-select-none', true)
360:        s.classed('user-select-none', true)

plots/gl2d/scene2d.js
151:    canvas.className += ' user-select-none';

@archmoj
Copy link
Contributor Author

archmoj commented Sep 25, 2020

One could select annotations and data text on master at the moment. So if we want to keep them as they are, I could make the adjustments?

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Let's also remove the .style('user-select', 'none') in sankey and par co ords, but then this looks good to go! 💃

@archmoj
Copy link
Contributor Author

archmoj commented Sep 25, 2020

@alexcjohnson
Seems we cannot remove user-select calls is sankey and parcoords as tried in 89e1342.
So I reverted that commit.

@alexcjohnson
Copy link
Collaborator

@alexcjohnson
Seems we cannot remove user-select calls is sankey and parcoords as tried in 89e1342.
So I reverted that commit.

That commit also removes the user-select-none class from the main div

@archmoj archmoj merged commit abbabe4 into master Sep 25, 2020
@archmoj archmoj deleted the fix5021-disable-text-selection branch September 25, 2020 21:43
@archmoj archmoj added this to the v1.56.0 milestone Sep 27, 2020
@bharatkrishna
Copy link

Is there a way to override this when using dash so that I can select axis values. This is with reference to this post on plotly forums.

@archmoj
Copy link
Contributor Author

archmoj commented Dec 6, 2020

Is there a way to override this when using dash so that I can select axis values. This is with reference to this post on plotly forums.

Not at the moment. But you could try removing 'user-select-none': true CSS from the svg container.

@bharatkrishna
Copy link

@archmoj how do I do that? In Dash, graph_objects.Scatter doesn't seem to have any argument to override the CSS. Or do I set 'user-select-none': false as the style of the Div which contains the plot svg?

@archmoj
Copy link
Contributor Author

archmoj commented Dec 6, 2020

@archmoj how do I do that? In Dash, graph_objects.Scatter doesn't seem to have any argument to override the CSS. Or do I set 'user-select-none': false as the style of the Div which contains the plot svg?

Hmm that may not be going to work.
Curious to know how selecting text is useful in your app. You can open a feature request.

@bharatkrishna
Copy link

bharatkrishna commented Dec 6, 2020

Hmm that may not be going to work.
Curious to know how selecting text is useful in your app. You can open a feature request.

Yes it was important in my app. The x-axis items contained timestamps or serial numbers I copy-paste into another application to get more details. I.e when I see certain upswings or downswings in the line plot, I copy x-axis items to examine them further. In case of items like timestamps, it is not easy to re-type them but rather copy-paste them is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable text selection
3 participants