Skip to content

Commit

Permalink
fix(vertical-item): update height after render when the item is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjmcgrath committed Aug 4, 2016
1 parent 49d3694 commit c639903
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
5 changes: 3 additions & 2 deletions addon/components/vertical-item/component.js
Expand Up @@ -3,7 +3,8 @@ import layout from './template';
import getOwner from 'ember-getowner-polyfill';

const {
Component
Component,
run
} = Ember;

/*
Expand Down Expand Up @@ -52,7 +53,7 @@ export default Component.extend({
if (!this.alwaysUseDefaultHeight) {
this.element.style.height = undefined;
}
this.updateHeight();
run.schedule('afterRender', this, this.updateHeight);
},

/*
Expand Down
33 changes: 33 additions & 0 deletions tests/integration/components/vertical-collection-test.js
Expand Up @@ -71,6 +71,39 @@ test('Adds classes to vertical-items', function(assert) {
});
});

test('Scroll to last item when actual item sizes are significantly larger than default item size.', function(assert) {
assert.expect(1);

this.set('items', new Array(50).fill({ text: 'b' }));

this.render(hbs`
<div style="height: 200px; width: 100px;" class="scrollable">
{{#vertical-collection
defaultHeight=10
alwaysUseDefaultHeight=false
bufferSize=0
content=items as |item i|}}
<div style="height: 100px;">{{item.text}} {{i}}</div>
{{/vertical-collection}}
</div>
`);

const scrollable = this.$('.scrollable');
const waitForScroll = new Ember.RSVP.Promise((resolve) => scrollable.scroll(resolve));

return wait()
.then(() => {
// Jump to bottom.
scrollable.scrollTop(scrollable.get(0).scrollHeight);
})
.then(waitForScroll)
.then(wait)
.then(() => {
assert.equal(scrollable.find('div:last').html(), 'b 49', 'the last item in the list should be rendered');
});
});


/*
test("The Collection Reveals it's children when `renderAllInitially` is true.", function(assert) {
assert.expect(1);
Expand Down

0 comments on commit c639903

Please sign in to comment.