If drawing a way, don't hover on a node that was just placed

(closes #3974)
This commit is contained in:
Bryan Housel
2017-04-26 13:33:21 -04:00
parent 8520e06c5a
commit 5ca4246a6d
4 changed files with 23 additions and 8 deletions

View File

@@ -13,9 +13,10 @@ import { utilRebind } from '../util/rebind';
Only one of these elements can have the :hover pseudo-class, but all of them will
have the .hover class.
*/
export function behaviorHover() {
export function behaviorHover(context) {
var dispatch = d3.dispatch('hover'),
_selection = d3.select(null),
newNode = null,
buttonDown,
altDisables,
target;
@@ -51,6 +52,7 @@ export function behaviorHover() {
var hover = function(selection) {
_selection = selection;
newNode = null;
_selection
.on('mouseover.hover', mouseover)
@@ -99,7 +101,15 @@ export function behaviorHover() {
_selection.selectAll('.hover-suppressed')
.classed('hover-suppressed', false);
if (target instanceof osmEntity) {
if (target instanceof osmEntity && target !== newNode) {
// 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;
return;
}
var selector = '.' + target.id;
if (target.type === 'relation') {

View File

@@ -17,7 +17,8 @@ export function svgMidpoints(projection, context) {
return function drawMidpoints(selection, graph, entities, filter, extent) {
var layer = selection.selectAll('.layer-hit');
if (context.mode().id !== 'select') {
var mode = context.mode();
if (mode && mode.id !== 'select') {
layer.selectAll('g.midpoint').remove();
return;
}

View File

@@ -4,7 +4,8 @@ describe('iD.behaviorHover', function() {
beforeEach(function() {
container = d3.select('body').append('div');
context = {
hover: function() {}
hover: function() {},
mode: function() { return { id: 'browse' }; }
};
});

View File

@@ -1,12 +1,15 @@
describe('iD.Map', function() {
var context, map;
var content, context, map;
beforeEach(function() {
content = d3.select('body').append('div');
context = iD.Context();
context.container(d3.select(document.createElement('div')));
map = context.map();
d3.select(document.createElement('div'))
.call(map);
content.call(map);
});
afterEach(function() {
content.remove();
});
describe('#zoom', function() {