From b720456ba84cd533cb5001edb3b5d472eed011cf Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Mon, 24 Jul 2017 11:36:18 -0400 Subject: [PATCH] Make expandable sidebar sections work with incognito mode In other words, don't rely on context.storage() working (re: #4159) --- modules/ui/preset.js | 4 +++- modules/ui/raw_tag_editor.js | 17 ++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/ui/preset.js b/modules/ui/preset.js index 677b35c0b..4e93d4770 100644 --- a/modules/ui/preset.js +++ b/modules/ui/preset.js @@ -16,6 +16,7 @@ import { export function uiPreset(context) { var dispatch = d3.dispatch('change'), + expandedPreference = (context.storage('preset_fields.expanded') !== 'false'), state, fieldsArr, preset, @@ -84,12 +85,13 @@ export function uiPreset(context) { function presets(selection) { selection.call(uiDisclosure() .title(t('inspector.all_fields')) - .expanded(context.storage('preset_fields.expanded') !== 'false') + .expanded(expandedPreference) .on('toggled', toggled) .content(content) ); function toggled(expanded) { + expandedPreference = expanded; context.storage('preset_fields.expanded', expanded); } } diff --git a/modules/ui/raw_tag_editor.js b/modules/ui/raw_tag_editor.js index 846d60797..c3bbb4f8a 100644 --- a/modules/ui/raw_tag_editor.js +++ b/modules/ui/raw_tag_editor.js @@ -15,9 +15,10 @@ import { export function uiRawTagEditor(context) { var taginfo = services.taginfo, dispatch = d3.dispatch('change'), - expanded = context.storage('raw_tag_editor.expanded') === 'true', - readOnlyTags = [], + expandedPreference = (context.storage('raw_tag_editor.expanded') === 'true'), + expandedCurrent = expandedPreference, updatePreference = true, + readOnlyTags = [], showBlank = false, newRow, state, @@ -31,13 +32,15 @@ export function uiRawTagEditor(context) { selection.call(uiDisclosure() .title(t('inspector.all_tags') + ' (' + count + ')') - .expanded(expanded) + .expanded(expandedCurrent) .on('toggled', toggled) .content(content) ); function toggled(expanded) { + expandedCurrent = expanded; if (updatePreference) { + expandedPreference = expanded; context.storage('raw_tag_editor.expanded', expanded); } if (expanded) { @@ -319,10 +322,10 @@ export function uiRawTagEditor(context) { if (!arguments.length) return preset; preset = _; if (preset.isFallback()) { - expanded = true; + expandedCurrent = true; updatePreference = false; } else { - expanded = context.storage('raw_tag_editor.expanded') === 'true'; + expandedCurrent = expandedPreference; updatePreference = true; } return rawTagEditor; @@ -344,8 +347,8 @@ export function uiRawTagEditor(context) { rawTagEditor.expanded = function(_) { - if (!arguments.length) return expanded; - expanded = _; + if (!arguments.length) return expandedCurrent; + expandedCurrent = _; updatePreference = false; return rawTagEditor; };