mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Fix escape keybind when conflicts ui is active
(re: 4351)
This commit is contained in:
@@ -47,7 +47,7 @@ var _isSaving = false;
|
||||
|
||||
export function modeSave(context) {
|
||||
var mode = { id: 'save' };
|
||||
var keybinding = d3_keybinding('select');
|
||||
var keybinding = d3_keybinding('save');
|
||||
|
||||
var loading = uiLoading(context)
|
||||
.message(t('save.uploading'))
|
||||
@@ -103,6 +103,7 @@ export function modeSave(context) {
|
||||
}
|
||||
|
||||
if (!_isSaving) {
|
||||
keybindingOff();
|
||||
context.container().call(loading); // block input
|
||||
_isSaving = true;
|
||||
}
|
||||
@@ -372,6 +373,7 @@ export function modeSave(context) {
|
||||
.on('cancel', function() {
|
||||
history.pop();
|
||||
selection.remove();
|
||||
keybindingOn();
|
||||
})
|
||||
.on('save', function() {
|
||||
for (var i = 0; i < _conflicts.length; i++) {
|
||||
@@ -396,12 +398,12 @@ export function modeSave(context) {
|
||||
|
||||
|
||||
function showErrors() {
|
||||
var selection = uiConfirm(context.container());
|
||||
|
||||
keybindingOn();
|
||||
context.history().pop();
|
||||
loading.close();
|
||||
_isSaving = false;
|
||||
|
||||
var selection = uiConfirm(context.container());
|
||||
selection
|
||||
.select('.modal-section.header')
|
||||
.append('h3')
|
||||
@@ -472,16 +474,24 @@ export function modeSave(context) {
|
||||
}
|
||||
|
||||
|
||||
function keybindingOn() {
|
||||
d3_select(document)
|
||||
.call(keybinding.on('⎋', cancel, true));
|
||||
}
|
||||
|
||||
|
||||
function keybindingOff() {
|
||||
d3_select(document)
|
||||
.call(keybinding.off);
|
||||
}
|
||||
|
||||
|
||||
mode.enter = function() {
|
||||
function done() {
|
||||
context.ui().sidebar.show(commit);
|
||||
}
|
||||
|
||||
keybinding
|
||||
.on('⎋', cancel, true);
|
||||
|
||||
d3_select(document)
|
||||
.call(keybinding);
|
||||
keybindingOn();
|
||||
|
||||
context.container().selectAll('#content')
|
||||
.attr('class', 'inactive');
|
||||
@@ -509,7 +519,7 @@ export function modeSave(context) {
|
||||
mode.exit = function() {
|
||||
_isSaving = false;
|
||||
|
||||
keybinding.off();
|
||||
keybindingOff();
|
||||
|
||||
context.container().selectAll('#content')
|
||||
.attr('class', 'active');
|
||||
|
||||
@@ -5,6 +5,8 @@ import {
|
||||
select as d3_select
|
||||
} from 'd3-selection';
|
||||
|
||||
import { d3keybinding as d3_keybinding } from '../lib/d3.keybinding.js';
|
||||
|
||||
import { t } from '../util/locale';
|
||||
import { JXON } from '../util/jxon';
|
||||
import { geoExtent } from '../geo';
|
||||
@@ -17,11 +19,35 @@ import { utilRebind } from '../util/rebind';
|
||||
|
||||
export function uiConflicts(context) {
|
||||
var dispatch = d3_dispatch('cancel', 'save');
|
||||
var keybinding = d3_keybinding('conflicts');
|
||||
var _origChanges;
|
||||
var _conflictList;
|
||||
|
||||
|
||||
function keybindingOn() {
|
||||
d3_select(document)
|
||||
.call(keybinding.on('⎋', cancel, true));
|
||||
}
|
||||
|
||||
function keybindingOff() {
|
||||
d3_select(document)
|
||||
.call(keybinding.off);
|
||||
}
|
||||
|
||||
function tryAgain() {
|
||||
keybindingOff();
|
||||
dispatch.call('save');
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
keybindingOff();
|
||||
dispatch.call('cancel');
|
||||
}
|
||||
|
||||
|
||||
function conflicts(selection) {
|
||||
keybindingOn();
|
||||
|
||||
var header = selection
|
||||
.append('div')
|
||||
.attr('class', 'header fillL');
|
||||
@@ -29,7 +55,7 @@ export function uiConflicts(context) {
|
||||
header
|
||||
.append('button')
|
||||
.attr('class', 'fr')
|
||||
.on('click', function() { dispatch.call('cancel'); })
|
||||
.on('click', cancel)
|
||||
.call(svgIcon('#icon-close'));
|
||||
|
||||
header
|
||||
@@ -102,13 +128,13 @@ export function uiConflicts(context) {
|
||||
.attr('disabled', _conflictList.length > 1)
|
||||
.attr('class', 'action conflicts-button col6')
|
||||
.text(t('save.title'))
|
||||
.on('click.try_again', function() { dispatch.call('save'); });
|
||||
.on('click.try_again', tryAgain);
|
||||
|
||||
buttons
|
||||
.append('button')
|
||||
.attr('class', 'secondary-action conflicts-button col6')
|
||||
.text(t('confirm.cancel'))
|
||||
.on('click.cancel', function() { dispatch.call('cancel'); });
|
||||
.on('click.cancel', cancel);
|
||||
}
|
||||
|
||||
|
||||
@@ -149,8 +175,8 @@ export function uiConflicts(context) {
|
||||
.attr('href', '#')
|
||||
.text(function(d) { return d.name; })
|
||||
.on('click', function(d) {
|
||||
zoomToEntity(d.id);
|
||||
d3_event.preventDefault();
|
||||
zoomToEntity(d.id);
|
||||
});
|
||||
|
||||
var details = enter
|
||||
@@ -186,6 +212,8 @@ export function uiConflicts(context) {
|
||||
(i === 1 && index === _conflictList.length - 1) || null;
|
||||
})
|
||||
.on('click', function(d, i) {
|
||||
d3_event.preventDefault();
|
||||
|
||||
var container = parent.select('.conflict-container');
|
||||
var sign = (i === 0 ? -1 : 1);
|
||||
|
||||
@@ -195,8 +223,6 @@ export function uiConflicts(context) {
|
||||
|
||||
container
|
||||
.call(showConflict, index + sign);
|
||||
|
||||
d3_event.preventDefault();
|
||||
});
|
||||
|
||||
item.exit()
|
||||
|
||||
Reference in New Issue
Block a user