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

Infinite list with listenWindowScroll doesn't work most of the time #2546

Closed
1 task
dabide opened this issue Oct 7, 2020 · 3 comments
Closed
1 task

Infinite list with listenWindowScroll doesn't work most of the time #2546

dabide opened this issue Oct 7, 2020 · 3 comments

Comments

@dabide
Copy link

dabide commented Oct 7, 2020

Issue type

I'm submitting a ... (check one with "x")

  • [ x] bug report
  • feature request

Issue description

Current behavior:

Using nbInfiniteList in combination with listenWindowScroll almost always results in the following error, which results in NbInfiniteListDirective not receiving any scroll events.

ERROR TypeError: Cannot read property 'nativeElement' of undefined
    at NbLayoutComponent.getDimensions (index.js:10644)
    at SafeSubscriber._next (index.js:10539)
    at SafeSubscriber.__tryOrUnsub (Subscriber.js:183)
    at SafeSubscriber.next (Subscriber.js:122)
    at Subscriber._next (Subscriber.js:72)
    at Subscriber.next (Subscriber.js:49)
    at TakeUntilSubscriber._next (Subscriber.js:72)
    at TakeUntilSubscriber.next (Subscriber.js:49)
    at Subject.next (Subject.js:39)
    at Observable._subscribe (index.js:2134)

It probably is some kind of race condition, but I can't find out where.

Expected behavior:

Infinite scroll with listenWindowScroll should work as advertised.

Steps to reproduce:

Just refresh https://www.akveo.com/ngx-admin/pages/layout/infinite-list a couple of times, and the error message will show in the console.

OS: Windows 10/Chrome and Ubuntu/Firefox

@dabide dabide changed the title Infinite list with listenWindowScroll mostly doesn't work Infinite list with listenWindowScroll doesn't work most of the time Oct 7, 2020
@jrasm91
Copy link

jrasm91 commented May 11, 2021

  1. scrollableContainerRef is a ViewChild() of LayoutComponent here
  2. getDimensions() is somehow called before ngAfterViewInit(), meaning that the scrollableContainerRef hasn't been loaded/set yet. This causes the cannot read property 'nativeElement' of undefined error.
  3. I believe this is caused because of this line here.

If the subscription in 3. was setup in ngAfterViewInit() I believe it would fix the issue.

@jrasm91
Copy link

jrasm91 commented May 11, 2021

Removing windowMode from <nb-layout>, per this comment also seemed to fix the issue for me.

@evtkhvch
Copy link
Contributor

Fixed in #2949

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