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

_getAnchor: negative _first when calling scrollToIndex #142

Open
jpzwarte opened this issue May 20, 2022 · 4 comments
Open

_getAnchor: negative _first when calling scrollToIndex #142

jpzwarte opened this issue May 20, 2022 · 4 comments

Comments

@jpzwarte
Copy link

jpzwarte commented May 20, 2022

I'm working on a combo-box component. The overlay contains a <lit-virtualizer> element with the list. When I open the overlay and there is a selected item, I scroll the virtualizer to that item (centered) using virtualizer.scrollToIndex(selectedIndex, 'center');

Now if I do this, before the overlay is visible, I get the _getAnchor: negative _first message in the console and it scrolls to the incorrect location. When I do this after the overlay is visible, it scrolls to the correct item in the list, but it "jumps": the original position of the list is briefly visible. See the video below.

Screen.Recording.2022-05-20.at.16.54.02.mov
@graynorton
Copy link

Thanks for the bug report, @jpzwarte. I don't suppose you have a repro case we can run? A minimal repro in the Lit Playground would be ideal, but anything is better than nothing.

We've recently been working on a pretty thorough overhaul of virtualizer's "scroll-to" functionality, including a way to declaratively specify the scroll position on the initial render. I think this should meet your needs, but I'd like to make sure these issues in the imperative case are handled as well.

@jpzwarte
Copy link
Author

Sounds good! I need to debug the situation a bit more. Seeing some other weird stuff that I'm not sure is not related to the way I provide the items to the virtualizer. (I'm using the VirtualArray technique from the examples to do something similar).

@jpzwarte
Copy link
Author

jpzwarte commented May 23, 2022

@graynorton affaict, what happens is that when calling scrollToIndex() before the overlay is shown:
Screenshot 2022-05-23 at 10 26 43

The first _first is 0 is from before I triggered opening the overlay.

  • _first is XX is a logpoint in flow.ts on line 373
  • scrollToIndex is XX is a logpoint in flow.ts on line 312
  • _scrollPositionChanged is a logpoint in BaseLayout.ts on line 508
  • the error message is flow.ts line 236

@joekukish
Copy link
Contributor

@jpzwarte did you find a solution for this issue?

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