From 289c75fee1e947f5d6079fb70f0504b9421ddcce Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Tue, 7 May 2019 17:53:22 -0400 Subject: [PATCH] When showing tooltip, update disabled in case disabled states disagree (closes #6296) --- modules/ui/edit_menu.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/modules/ui/edit_menu.js b/modules/ui/edit_menu.js index b8acb3ce6..ce8d4aeac 100644 --- a/modules/ui/edit_menu.js +++ b/modules/ui/edit_menu.js @@ -71,18 +71,18 @@ export function uiEditMenu(context, operations) { .attr('stroke-linecap', 'round'); - var button = menu.selectAll('.edit-menu-item') + var buttons = menu.selectAll('.edit-menu-item') .data(operations); // enter - var buttonEnter = button.enter() + var buttonsEnter = buttons.enter() .append('g') .attr('class', function (d) { return 'edit-menu-item edit-menu-item-' + d.id; }) .attr('transform', function(d, i) { return 'translate(' + geoVecFloor([0, m + i * buttonHeight]).join(',') + ')'; }); - buttonEnter + buttonsEnter .append('rect') .attr('x', 4) .attr('width', buttonWidth) @@ -92,7 +92,7 @@ export function uiEditMenu(context, operations) { .on('mouseover', mouseover) .on('mouseout', mouseout); - buttonEnter + buttonsEnter .append('use') .attr('width', '20') .attr('height', '20') @@ -100,8 +100,8 @@ export function uiEditMenu(context, operations) { .attr('xlink:href', function (d) { return '#iD-operation-' + d.id; }); // update - button = buttonEnter - .merge(button) + buttons = buttonsEnter + .merge(buttons) .classed('disabled', function(d) { return d.disabled(); }); @@ -149,6 +149,12 @@ export function uiEditMenu(context, operations) { .style('top', tipY + 'px') .style('display', 'block') .html(uiTooltipHtml(d.tooltip(), d.keys[0], d.title)); + + // update disabled again, just in case tooltip and disabled state disagree + // https://github.com/openstreetmap/iD/issues/6296#issuecomment-489259027 + d3_select(this.parentNode) + .classed('disabled', d.disabled()); + } function mouseout() {