From 12f402c48b430e9a8b920767fcdf252f2fafcb32 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Mon, 6 Aug 2018 14:45:10 -0400 Subject: [PATCH] Disable Add Note '4' shortcut when notes layer is not enabled (also return to browse mode if notes or osm layers get disabled) (closes #5190) --- modules/ui/map_data.js | 6 ++++++ modules/ui/modes.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/ui/map_data.js b/modules/ui/map_data.js index 149f4693f..974e1c0ba 100644 --- a/modules/ui/map_data.js +++ b/modules/ui/map_data.js @@ -8,6 +8,7 @@ import { d3keybinding as d3_keybinding } from '../lib/d3.keybinding.js'; import { svgIcon } from '../svg'; import { t, textDirection } from '../util/locale'; import { tooltip } from '../util/tooltip'; +import { modeBrowse } from '../modes'; import { uiBackground } from './background'; import { uiDisclosure } from './disclosure'; import { uiHelp } from './help'; @@ -75,6 +76,11 @@ export function uiMapData(context) { var layer = layers.layer(which); if (layer) { layer.enabled(enabled); + + if (!enabled && (which === 'osm' || which === 'notes')) { + context.enter(modeBrowse(context)); + } + update(); } } diff --git a/modules/ui/modes.js b/modules/ui/modes.js index dbff2e88e..25aff9f83 100644 --- a/modules/ui/modes.js +++ b/modules/ui/modes.js @@ -60,7 +60,7 @@ export function uiModes(context) { modes.forEach(function(mode) { keybinding.on(mode.key, function() { - if (mode.id === 'add-note' && !notesEditable()) return; + if (mode.id === 'add-note' && !(notesEnabled() && notesEditable())) return; if (mode.id !== 'add-note' && !editable()) return; if (mode.id === context.mode().id) {