Don't copy when user has selected text manually

This commit is contained in:
alex 2015-07-12 08:59:24 +01:00 committed by Addy Osmani
parent 015db23a7b
commit c41ea7e08d

View File

@ -85,6 +85,11 @@ MaterialComponentsSnippets.prototype.onMouseClickHandler = function(snippet) {
'use strict'; 'use strict';
return function() { return function() {
if (window.getSelection().toString().length > 0) {
// user has selected some text manually
// don't do anything
return;
}
if (this.copyToClipboard(snippet)) { if (this.copyToClipboard(snippet)) {
snippet.classList.add(this.CssClasses_.COPIED); snippet.classList.add(this.CssClasses_.COPIED);
} }