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._first in virtual-repeat.js becomes negative when changing to smaller sized array #111

Closed
palktonderAtpowelno opened this Issue Aug 2, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@palktonderAtpowelno
Contributor

palktonderAtpowelno commented Aug 2, 2017

I'm submitting a bug report

  • Library Version:
    1.0.0-beta.3.1.0

Please tell us about your environment:

  • Operating System:
    Windows [10]

  • Node Version:
    6.11.1

  • NPM Version:
    3.10.10
  • JSPM OR Webpack AND Version
    webpack 1.13.3
  • Browser:
    all

  • Language:
    all

Current behavior:
Since the code allows this._first to be negative, the corresponding first item is not found and everything fails. The consequence is that the data used when styling the item is not available. Consequently it looks wrong and can't be clicked either

Expected/desired behavior:

  • What is the expected behavior?
    The code should allow for the content of the collection to be reduced without misbehaving. It should be possible to solve this by changing the code at line 267 in virtual-repeat.js (in the function _handleScroll) from:

    this._first = this._first < 0 ? 0 : this._first;
    if (this._first > this.items.length - this.elementsInView) {
    this._first = this.items.length - this.elementsInView;
    }

to

if (this._first > this.items.length - this.elementsInView) {
  this._first = this.items.length - this.elementsInView;
}
this._first = this._first < 0 ? 0 : this._first;

This ensures that this._first can never be negative

  • What is the motivation / use case for changing the behavior?
    To be able to reduce the number of items and still have the repeater behave correctly
@palktonderAtpowelno

This comment has been minimized.

Show comment
Hide comment
@palktonderAtpowelno

palktonderAtpowelno Aug 5, 2017

Contributor

I've tried to create a pull request for this issue using Github for desktop, but for some reason I don't have permission to push to Github using the description in the contribution page. Unless I get help with that I need somebody else to look at this bug. I really need help with this as we already use it in our solution (yes, I know it's in preview, but... :-( )

Contributor

palktonderAtpowelno commented Aug 5, 2017

I've tried to create a pull request for this issue using Github for desktop, but for some reason I don't have permission to push to Github using the description in the contribution page. Unless I get help with that I need somebody else to look at this bug. I really need help with this as we already use it in our solution (yes, I know it's in preview, but... :-( )

palktonderAtpowelno added a commit to palktonderAtpowelno/ui-virtualization that referenced this issue Aug 6, 2017

fix(virtual-repeat): Correctly handle items array smaller than elemen…
…ts in view

this._first becomes negative if this.items.length is smaller than
this.elementsInView. This negative index creates problems retrieving
data

This closes issue #111. Also the test 'VirtualRepeat Integration
infinite scroll handles getting next data set with small page size' is
changed because it wrongfully expected scrolling when the number of
items were less than the elements in the view.

@AStoker AStoker closed this in 4fbea6b Aug 28, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment