Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken onScroll handler after v1.8.6 #397

Merged
merged 2 commits into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
26 changes: 26 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,29 @@ 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));

this.setProperties({
table,
currentScrollY: 0,
onScroll() {
assert.ok(true, 'onScroll worked');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-picky, but do we want to check for e.target.scrollTop = 300?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual value was slightly different, probably because of row heights, table size, etc. Just wanted to check the event handler was properly called on scroll.

Should I improve the test to also check for position or is this test good enough?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's probably because 300 > than the total row heights combined, did you try with a smaller value (in my experience it matches).
that being said even something as assert.ok(e.target.scrollTop > 0) proves your point that it did scroll.
assert.equal(e.target.scrollTop, scrollTopAmount) verifies that it scrolled the requested amount as well as it scrolled.

if it's not too hard I would try to add it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 😃 .

300 was indeed too much scrolling for this test, 50 does the trick.

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(300).scroll();
});