diff --git a/www/common/inner/sidebar-layout.js b/www/common/inner/sidebar-layout.js index ca4a5bcc6..7af940cd8 100644 --- a/www/common/inner/sidebar-layout.js +++ b/www/common/inner/sidebar-layout.js @@ -270,8 +270,17 @@ define([ sidebar.addItem = (key, get, options) => { const safeKey = keyToCamlCase(key); + const div = h(`div.cp-sidebarlayout-element`, { + 'data-item': key, + style: 'display:none;' + }); + items[key] = div; + $rightside.append(div); get((content) => { - if (content === false) { return; } + if (content === false) { + delete items[key]; + return void $(div).remove(); + } options = options || {}; const title = options.noTitle ? undefined : h('label.cp-item-label', { id: `cp-${app}-${key}` @@ -281,16 +290,7 @@ define([ if (hint && options.htmlHint) { hint.innerHTML = Messages[`${app}_${safeKey}Hint`]; } - const div = h(`div.cp-sidebarlayout-element`, { - 'data-item': key, - style: 'display:none;' - }, [ - title, - hint, - content - ]); - items[key] = div; - $rightside.append(div); + $(div).append(title).append(hint).append(content); }); };