Fix issue where text could not be copied while a feature was selected (close #7908)

This commit is contained in:
Quincy Morgan
2020-09-04 10:49:02 -04:00
parent 03ca12741f
commit 295c53810f
2 changed files with 10 additions and 11 deletions
+3
View File
@@ -9,7 +9,10 @@ export function behaviorOperation(context) {
// prevent operations during low zoom selection
if (!context.map().withinEditableZoom()) return;
if (_operation.availableForKeypress && !_operation.availableForKeypress()) return;
d3_event.preventDefault();
var disabled = _operation.disabled();
if (disabled) {
+7 -11
View File
@@ -1,5 +1,3 @@
import { event as d3_event } from 'd3-selection';
import { t } from '../core/localizer';
import { behaviorOperation } from '../behavior/operation';
import { uiCmd } from '../ui/cmd';
@@ -19,10 +17,6 @@ export function operationCopy(context, selectedIDs) {
var operation = function() {
if (!getSelectionText()) {
d3_event.preventDefault();
}
var graph = context.graph();
var selected = groupEntities(getFilteredIdsToCopy(), graph);
var canCopy = [];
@@ -97,11 +91,6 @@ export function operationCopy(context, selectedIDs) {
}
function getSelectionText() {
return window.getSelection().toString();
}
operation.available = function() {
return getFilteredIdsToCopy().length > 0;
};
@@ -116,6 +105,13 @@ export function operationCopy(context, selectedIDs) {
};
operation.availableForKeypress = function() {
var selection = window.getSelection && window.getSelection();
// if the user has text selected then let them copy that, not the selected feature
return !selection || !selection.toString();
};
operation.tooltip = function() {
var disable = operation.disabled();
return disable ?