Skip to content

Commit

Permalink
Fix broken onScroll handler after v1.8.6 (#397)
Browse files Browse the repository at this point in the history
* Fix broken onScroll handler after v1.8.6

After fixing deprecation message for onScroll, a typo was
introduced by using `onScrollToY` instead of `onScrollY`. This
PR resolves this problem by using the correct event handler and
adds a basic test to ensure the event gets fired properly.

* Test scroll value too

Instead of just testing event handler being called, also test
the value of the actual scrolling.
  • Loading branch information
Erick Ruiz de Chavez authored and alexander-alvarez committed Apr 28, 2017
1 parent 31b5ee8 commit fdcd31e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion addon/templates/components/lt-body.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
virtualScrollbar=useVirtualScrollbar
autoHide=autoHideScrollbar
scrollTo=targetScrollOffset
onScrollToY=(action 'onScroll')
onScrollY=(action 'onScroll')
}}
<div id={{concat tableId '_inline_head'}} class="lt-inline lt-head"></div>

Expand Down
2 changes: 1 addition & 1 deletion addon/templates/components/lt-scrollable.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
horizontal=horizontal
vertical=vertical
scrollToY=scrollTo
onScrollToY=onScrollToY
onScrollY=onScrollY
as |scrollbar|
}}
{{yield}}
Expand Down
27 changes: 27 additions & 0 deletions tests/integration/components/light-table-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,30 @@ test('passed in components can have computed properties', function(assert) {

assert.equal(this.$('.custom-row.is-active').length, 0, 'none of the items are active');
});

test('onScroll', function(assert) {
let done = assert.async();
let table = new Table(Columns, createUsers(10));
let expectedScroll = 50;

this.setProperties({
table,
onScroll(actualScroll) {
assert.ok(true, 'onScroll worked');
assert.equal(actualScroll, expectedScroll, 'scroll position is correct');
done();
}
});

this.render(hbs `
{{#light-table table height='40vh' as |t|}}
{{t.head fixed=true}}
{{t.body
useVirtualScrollbar=true
onScroll=onScroll
}}
{{/light-table}}
`);

this.$('.tse-scroll-content').scrollTop(expectedScroll).scroll();
});

0 comments on commit fdcd31e

Please sign in to comment.