diff --git a/modules/ui/disclosure.js b/modules/ui/disclosure.js index f50ef2bfa..6b9f3f7c7 100644 --- a/modules/ui/disclosure.js +++ b/modules/ui/disclosure.js @@ -51,14 +51,17 @@ export function uiDisclosure(context, key, expandedDefault) { var wrap = selection.selectAll('.disclosure-wrap') .data([0]); + // enter/update wrap = wrap.enter() .append('div') .attr('class', 'disclosure-wrap disclosure-wrap-' + key) - .merge(wrap); + .merge(wrap) + .classed('hide', !_expanded); - wrap - .classed('hide', !_expanded) - .call(_content); + if (_expanded) { + wrap + .call(_content); + } function toggle() { @@ -78,6 +81,11 @@ export function uiDisclosure(context, key, expandedDefault) { : (textDirection === 'rtl') ? '#iD-icon-backward' : '#iD-icon-forward' ); + if (_expanded) { + wrap + .call(_content); + } + wrap .call(uiToggle(_expanded)); @@ -86,30 +94,30 @@ export function uiDisclosure(context, key, expandedDefault) { }; - disclosure.title = function(_) { + disclosure.title = function(val) { if (!arguments.length) return _title; - _title = _; + _title = val; return disclosure; }; - disclosure.expanded = function(_) { + disclosure.expanded = function(val) { if (!arguments.length) return _expanded; - _expanded = _; + _expanded = val; return disclosure; }; - disclosure.updatePreference = function(_) { + disclosure.updatePreference = function(val) { if (!arguments.length) return _updatePreference; - _updatePreference = _; + _updatePreference = val; return disclosure; }; - disclosure.content = function(_) { + disclosure.content = function(val) { if (!arguments.length) return _content; - _content = _; + _content = val; return disclosure; }; diff --git a/test/spec/ui/raw_tag_editor.js b/test/spec/ui/raw_tag_editor.js index ac7212ef9..a6ec85bee 100644 --- a/test/spec/ui/raw_tag_editor.js +++ b/test/spec/ui/raw_tag_editor.js @@ -5,7 +5,8 @@ describe('iD.uiRawTagEditor', function() { taglist = iD.uiRawTagEditor(context) .entityID(entity.id) .preset({isFallback: function() { return false; }}) - .tags(tags); + .tags(tags) + .expanded(true); element = d3.select('body') .append('div')