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

AutoSizer does not show list items with scrollToIndex #691

Closed
ethankong113 opened this issue Jun 2, 2017 · 8 comments
Closed

AutoSizer does not show list items with scrollToIndex #691

ethankong113 opened this issue Jun 2, 2017 · 8 comments

Comments

@ethankong113
Copy link

Demo here: https://plnkr.co/edit/6GFoRcQrM3jdy3aYGvly?p=preview

I have a list that pans out when a user clicks the open button. However, when I use it with scrollToIndex to scroll to a specific list item, it seems to hide the items that are above the index. And if you change the index to a larger number, the entire list disappears. This problem goes away when you scroll onto the list, but it returns you to the top instead of the indexed item.

@bvaughn
Copy link
Owner

bvaughn commented Jun 2, 2017

Not sure what the demo is showing but it's not using AutoSizer correctly. (The width and height parameters are ignored in favor of hard-coded values.) Here's a fork that seems to work fine: https://plnkr.co/edit/5NsaqR?p=preview

Closing this for now since it seems to work okay for me. We can keep talking here though if I'm overlooking something. 😄

@bvaughn bvaughn closed this as completed Jun 2, 2017
@ethankong113
Copy link
Author

Are you saying that the AutoSizer can only pan out vertically instead of horizontally?

Did you see how the demo doesn't show the menu items before the scrollToIndex? Or you can check this one (https://plnkr.co/edit/uYtFXdNNw1a5CRwKgaO8?p=preview). When I pick a large scrollToIndex number... the entire list is missing.

@bvaughn
Copy link
Owner

bvaughn commented Jun 2, 2017

No. I was juust saying that the original Plnkr is strange. This is not how AutoSizer should be used:

<AutoSizer>
  {({height, width}) => ( // height and width are not used, so why use AutoSizer?
    <List
      width={this.state.open ? 500 : 0}
      height={700}

I think the problem you're reporting is that the combination of setting scrollToIndex with a height and/or width of 0 causes the scrollToIndex property to be ignored, since no cells are rendered when height or width are 0.

If you change...

width={this.state.open ? 500 : 0}

...to...

width={this.state.open ? 500 : 1}

...your example works. I'll re-open. Feel free to submit a PR if you'd like. 😄

@bvaughn bvaughn reopened this Jun 2, 2017
@ethankong113
Copy link
Author

Yes. I tried to do 1 instead of 0 and used a CSS visibility to hide the list. It works but it seems to be a hack.

@bvaughn
Copy link
Owner

bvaughn commented Jun 2, 2017

Yeah. I was just thrown by the original Plnkr b'c it seemed like it was doing things that weren't valid.

@ethankong113
Copy link
Author

I will see if there's a fix for this over the weekend :)

@bvaughn
Copy link
Owner

bvaughn commented Jun 13, 2017

Resolved via 67f9dc5

@bvaughn bvaughn closed this as completed Jun 13, 2017
@bvaughn
Copy link
Owner

bvaughn commented Jun 13, 2017

Fix released with 9.8.0

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