From 450039f967ad1b70ecf630fa915ab0c411e41a22 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Tue, 10 Feb 2015 19:55:22 +1030 Subject: [PATCH] Fix up bug with the way we hide list items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we use an #unless condition, then when the view is removed from the template, it is destroyed, and cannot be inserted again. So we’ll just keep the item there the whole time, and toggle its visibility with CSS. --- .../app/components/discussion/post-header/edited.js | 5 +++-- .../app/components/discussion/post-header/toggle.js | 3 ++- .../ember/app/templates/components/ui/item-list.hbs | 12 +++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/framework/core/ember/app/components/discussion/post-header/edited.js b/framework/core/ember/app/components/discussion/post-header/edited.js index e28f1b147..c81731a60 100644 --- a/framework/core/ember/app/components/discussion/post-header/edited.js +++ b/framework/core/ember/app/components/discussion/post-header/edited.js @@ -9,8 +9,9 @@ var precompileTemplate = Ember.Handlebars.compile; hover which details who edited the post and when. */ export default Ember.Component.extend({ - tagName: 'span', + tagName: 'li', classNames: ['post-edited'], + classNameBindings: ['hidden'], attributeBindings: ['title'], layout: precompileTemplate('{{fa-icon "pencil"}}'), @@ -20,7 +21,7 @@ export default Ember.Component.extend({ // In the context of an item list, this item will be hidden if the post // hasn't been edited, or if it's been hidden. - hideItem: Ember.computed('post.isEdited', 'post.isHidden', function() { + hidden: Ember.computed('post.isEdited', 'post.isHidden', function() { return !this.get('post.isEdited') || this.get('post.isHidden'); }), diff --git a/framework/core/ember/app/components/discussion/post-header/toggle.js b/framework/core/ember/app/components/discussion/post-header/toggle.js index cdef15650..714bdcd3c 100644 --- a/framework/core/ember/app/components/discussion/post-header/toggle.js +++ b/framework/core/ember/app/components/discussion/post-header/toggle.js @@ -9,9 +9,10 @@ var precompileTemplate = Ember.Handlebars.compile; */ export default Ember.Component.extend({ tagName: 'li', + classNameBindings: ['hidden'], layout: precompileTemplate('{{fa-icon "ellipsis-h"}}'), - hideItem: Ember.computed.not('post.isHidden'), + hidden: Ember.computed.not('post.isHidden'), actions: { toggle: function() { diff --git a/framework/core/ember/app/templates/components/ui/item-list.hbs b/framework/core/ember/app/templates/components/ui/item-list.hbs index 41542f982..d3e616153 100644 --- a/framework/core/ember/app/templates/components/ui/item-list.hbs +++ b/framework/core/ember/app/templates/components/ui/item-list.hbs @@ -1,9 +1,7 @@ {{#each item in listItems}} - {{#unless item.hideItem}} - {{#if item.isListItem}} - {{view item}} - {{else}} -
  • {{view item}}
  • - {{/if}} - {{/unless}} + {{#if item.isListItem}} + {{view item}} + {{else}} +
  • {{view item}}
  • + {{/if}} {{/each}}