diff --git a/core/menu_view.js b/core/menu_view.js index 73e56a4a..d9016153 100644 --- a/core/menu_view.js +++ b/core/menu_view.js @@ -102,6 +102,8 @@ MenuView.prototype.setItems = function(items) { if(this.complexItems) { this.itemFormat = this.itemFormat || '{text}'; } + + this.invalidateRenderCache(); } }; @@ -110,11 +112,19 @@ MenuView.prototype.getRenderCacheItem = function(index, focusItem = false) { return item && item[focusItem ? 'focus' : 'standard']; }; +MenuView.prototype.removeRenderCacheItem = function(index) { + delete this.renderCache[index]; +}; + MenuView.prototype.setRenderCacheItem = function(index, rendered, focusItem = false) { this.renderCache[index] = this.renderCache[index] || {}; this.renderCache[index][focusItem ? 'focus' : 'standard'] = rendered; }; +MenuView.prototype.invalidateRenderCache = function() { + this.renderCache = {}; +}; + MenuView.prototype.setSort = function(sort) { if(this.sorted || !Array.isArray(this.items) || 0 === this.items.length) { return; @@ -152,6 +162,8 @@ MenuView.prototype.removeItem = function(index) { this.focusedItemIndex = Math.max(this.focusedItemIndex - 1, 0); } + this.removeRenderCacheItem(index); + this.positionCacheExpired = true; };