Fix spacebar drawing and hover in Firefox - don't match active node

(closes #4016)
This commit is contained in:
Bryan Housel
2017-05-08 01:37:38 -04:00
parent c0a7f72115
commit 4ee5d7334b
3 changed files with 17 additions and 8 deletions
+5 -3
View File
@@ -124,6 +124,9 @@ export function behaviorDraw(context) {
function space() {
d3.event.preventDefault();
d3.event.stopPropagation();
var currSpace = context.mouse();
if (disableSpace && lastSpace) {
var dist = geoEuclideanDistance(lastSpace, currSpace);
@@ -139,13 +142,12 @@ export function behaviorDraw(context) {
disableSpace = true;
d3.select(window).on('keyup.space-block', function() {
disableSpace = false;
d3.select(window).on('keyup.space-block', null);
d3.event.preventDefault();
d3.event.stopPropagation();
disableSpace = false;
d3.select(window).on('keyup.space-block', null);
});
d3.event.preventDefault();
click();
}
+7
View File
@@ -255,6 +255,13 @@ export function behaviorDrawWay(context, wayId, index, mode, startGraph) {
// Avoid creating duplicate segments
if (origWay.areAdjacent(node.id, origWay.nodes[origWay.nodes.length - 1])) return;
// Clicks should not occur on the drawing node, however a space keypress can
// sometimes grab that node's datum (before it gets classed as `active`?) #4016
if (node.id === end.id) {
drawWay.add(node.loc);
return;
}
context.pop(tempEdits);
context.perform(
+5 -5
View File
@@ -16,7 +16,7 @@ import { utilRebind } from '../util/rebind';
export function behaviorHover(context) {
var dispatch = d3.dispatch('hover'),
_selection = d3.select(null),
newNode = null,
newId = null,
buttonDown,
altDisables,
target;
@@ -52,7 +52,7 @@ export function behaviorHover(context) {
var hover = function(selection) {
_selection = selection;
newNode = null;
newId = null;
_selection
.on('mouseover.hover', mouseover)
@@ -101,12 +101,12 @@ export function behaviorHover(context) {
_selection.selectAll('.hover-suppressed')
.classed('hover-suppressed', false);
if (target instanceof osmEntity && target !== newNode) {
if (target instanceof osmEntity && target.id !== newId) {
// If drawing a way, don't hover on a node that was just placed. #3974
var mode = context.mode() && context.mode().id;
if ((mode === 'draw-line' || mode === 'draw-area') && !newNode && target.type === 'node') {
newNode = target;
if ((mode === 'draw-line' || mode === 'draw-area') && !newId && target.type === 'node') {
newId = target.id;
return;
}