mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 04:31:57 +08:00
Fix up bug with the way we hide list items
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.
This commit is contained in:
parent
090e8c6061
commit
ffef6af403
@ -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');
|
||||
}),
|
||||
|
||||
|
@ -9,9 +9,10 @@ var precompileTemplate = Ember.Handlebars.compile;
|
||||
*/
|
||||
export default Ember.Component.extend({
|
||||
tagName: 'li',
|
||||
classNameBindings: ['hidden'],
|
||||
layout: precompileTemplate('<a href="#" class="btn btn-default btn-more" {{action "toggle"}}>{{fa-icon "ellipsis-h"}}</a>'),
|
||||
|
||||
hideItem: Ember.computed.not('post.isHidden'),
|
||||
hidden: Ember.computed.not('post.isHidden'),
|
||||
|
||||
actions: {
|
||||
toggle: function() {
|
||||
|
@ -1,9 +1,7 @@
|
||||
{{#each item in listItems}}
|
||||
{{#unless item.hideItem}}
|
||||
{{#if item.isListItem}}
|
||||
{{view item}}
|
||||
{{else}}
|
||||
<li>{{view item}}</li>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{#if item.isListItem}}
|
||||
{{view item}}
|
||||
{{else}}
|
||||
<li>{{view item}}</li>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user