Skip to content

startIndex missing items above #359

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

Closed
klscmms opened this issue Apr 30, 2025 · 2 comments
Closed

startIndex missing items above #359

klscmms opened this issue Apr 30, 2025 · 2 comments

Comments

@klscmms
Copy link

klscmms commented Apr 30, 2025

Hello,

First of all thank you for helping on the last issue I had on adaptor.reload(index) on a dynamic height componenet (#344).
I'm encountering another issue, this time related to the startIndex in settings.

Description
The startIndex in the settings does bring me to the target index, but sometimes it cuts off all the items above the startIndex. Other times, it cuts off only two items above it.

Expected Behavior
The startIndex should scroll to the target index while preserving all items in the list.

Setup

this.selectedItemsSource = new Datasource<EstimateOption>({
    get: (index, count, success) => {
        success(this.selectedItems.slice(index, index + count));
    },
    settings: {
        startIndex: this.startIndex || this.DEFAULT_INDEX,
        infinite: true
    }
});

The EstimateOption type:

export interface EstimateOption {
    id: string;
    label: string;
    imageId: string;
    basePrice: number;
    minimumQuantity: number;
    description: string;
    quantity: number;
    lineId?: string;
}

Issue Demo
Please check this video,:
The list starts with "Banner Installation". When I initialize the scroll by clicking the last item, "Travel", it correctly brings me to that item, but everything above "First Service" is cut off.

Here is another video that shows the same issue and all the items above the target item are missing.
When initializing the scroll by clicking other items, some of them result in missing items above the clicked one.

Thank you.

@dhilt
Copy link
Owner

dhilt commented May 5, 2025

@klscmms Hello!

It looks like there might be an indexing issue, but I can’t confirm without a demo. In most cases, the datasource logic is the place where you need to have a fix. I have prepared a demo that might help: https://stackblitz.com/edit/ngx-ui-scroll-start-index-demo. It shows an example of "bad" and "good" datasource logic in regard of start-index API. If this doesn't help, I would ask you to

@klscmms
Copy link
Author

klscmms commented May 13, 2025

Thank you, the advanced datasource logic works!

@klscmms klscmms closed this as completed May 13, 2025
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

2 participants