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

this.$().offset().top undefined at times #137

Closed
venkz opened this issue Feb 17, 2016 · 8 comments
Closed

this.$().offset().top undefined at times #137

venkz opened this issue Feb 17, 2016 · 8 comments

Comments

@venkz
Copy link

venkz commented Feb 17, 2016

I was not using the destroyOnInfinity flag but I still run into this issue when I run Ember test suite on pages that have infinity scroll. It is not reproducible consistently but I see this quite often.

Could you give me any clue as to why this occurs and what is happening here...

I updated to 0.2.1 V hoping it will fix the issue but no luck!

path: components/infinity-loader.js : 46

@kellyselden
Copy link
Collaborator

can you link to a repo where we can see the error reproduced?

@venkz
Copy link
Author

venkz commented Feb 17, 2016

exact error: TypeError: this.$(...) is undefined

import Ember from 'ember';
import InfinityRoute from 'ember-infinity/mixins/route';

export default Ember.Route.extend(InfinityRoute, {
model() {
return this.infinityModel(modelName, {
startingPage: 1,
perPage: 30,
sortBy: serializedSortConfig,
data: advancedFilterObject,
});
}
});

in the template I am just doing
{{infinity-loader infinityModel=model}}

Now I have various test cases that make use of this page that has the infinite scroll. The test cases are mostly related to server side filters..

I runs normally at times but it also fails quite often.

@kellyselden
Copy link
Collaborator

I don't see anything wrong with that code. It might be that the issue is not related to ember-infinity.

@venkz
Copy link
Author

venkz commented Feb 17, 2016

Issue is related to ember-infinity code... Each time it errors out in the same line I pointed to. It is trying to fetch the page offset top and failing to find that when test cases run.

It works fine when I just play manually with this page by selecting various sort orders and filters and infinity loader does the job. When I run test cases which are usually a lot faster than manual clicks, it bails out at times!!!

could this be related to an open issue #100 ???

@hhff hhff changed the title this.$().offset().top undefined at times!! ?? this.$().offset().top undefined at times Feb 17, 2016
@hhff
Copy link
Collaborator

hhff commented Feb 18, 2016

HI @venkz ! This isn't related to #100

Seeing as you're only getting this error in testing, I'm pretty confident that what is happening is:

  1. You're rendering a route that has infinity loader in a test
  2. That test is finished
  3. The infinityLoader schedules this method
  4. The test (& infinityLoader) is torn down before the afterRender queue is run
  5. Line 46 runs after the element is destroyed

Can you please create a file called your-app/components/infinity-loader.js, and inside put:

import InfinityLoader from 'ember-infinity/components/infinity-loader';

export default InfintyLoader.extend({
  _loadMoreIfNeeded() {
    if (this.isDestroyed) { return; }
    return this._super(...arguments);
  }
});

And let me know if that fixes the bug? Thankyou!

@venkz
Copy link
Author

venkz commented Feb 18, 2016

Hey @hhff This is exactly where I was getting to. I shall try it out and let you know.

@venkz
Copy link
Author

venkz commented Feb 18, 2016

@hhff , I tried creating a component on my own extending from your's and did run my test suite for 5 times before confirming this. IT WORKS 👍

I submitted a pull request making this fix thinking it would be easier for you guys to integrate.

Thanks for all the help. Appreciate your work..

@venkz venkz closed this as completed Feb 18, 2016
@hhff
Copy link
Collaborator

hhff commented Feb 18, 2016

gnarly!! thanks @venkz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants