Skip to content

Conversation

LFDanLu
Copy link
Member

@LFDanLu LFDanLu commented May 17, 2021

Closes #1885

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Test steps:

  1. Go to http://localhost:9003/?path=/story/tableview--controlled-selection-mode
  2. change selection mode to multiple
  3. Select any table row
  4. Change selection mode to none. Note the table shouldn't throw

🧢 Your Project:

fixes issue 1885, the checkbox cell no longer has layoutInfo when selectionMode goes from multiple to none
@adobe-bot
Copy link

Build successful! 🎉

Comment on lines +314 to +317
// If no layoutInfo, item has been deleted/removed.
if (!layoutInfo) {
return false;
}
Copy link
Member Author

@LFDanLu LFDanLu May 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternative/supplemental fix: maybe change https://github.com/adobe/react-spectrum/blob/main/packages/@react-stately/virtualizer/src/Virtualizer.ts#L907 to something like

let changed = !this.layout.getLayoutInfo(key) || this.layout.updateItemSize(key, size);

aka if that key doesn't have layout info, don't bother calling updateItemSize and perform a relayout (or maybe don't relayout? Think it might be "don't perform a relayout" in this case since the test complains about the max update depth being exceeded when I set return true here)

@adobe-bot
Copy link

Build successful! 🎉

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested in Chrome
i do see your other question, I don't have an opinion right now because it wouldn't really be informed. I'm happy to see how this one goes. Though if you want to elaborate on the two approaches (pros/cons?) maybe that'd help me form more of an opinion

@LFDanLu
Copy link
Member Author

LFDanLu commented May 18, 2021

The pro of adding/using the virtualizer change would be that it is perhaps a more central change (it is the one calling layout.updateItemSize). However, it makes the assumption that if this.layout.getLayoutInfo(key) is undefined we don't need to call layout.updateItemSize making an assumption on how updateItemSize is written (this might be a reasonable assumption to make though). Additionally, I'm not entirely sure if we should call relayout when this situation occurs, but the test I wrote breaks when it does get called so I'm leaning towards no

@devongovett devongovett removed their assignment May 20, 2021
@adobe-bot
Copy link

Build successful! 🎉

@LFDanLu LFDanLu merged commit 725559b into main May 20, 2021
@LFDanLu LFDanLu deleted the issue_1885 branch May 20, 2021 17:01
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

Successfully merging this pull request may close these issues.

RS3 Table [Alpha] - Cannot set property 'estimatedSize' of undefined
5 participants