Nested column bug when column nodes are cached
- Dominant language
- TypeScript
- Stars
- 15.9k
- Forks
- 1.6k
- Avg merge
- 3d 9m
- Merged PRs (30d)
- 59
Description
# 🐛 Bug Report
The `Column` class has a “bit of a hack” to call `updateContext` to add a column to the `context`’s list of columns:
https://github.com/adobe/react-spectrum/blob/f2a118718d0a807d4a852af046c45811afab9578/packages/%40react-stately/table/src/Column.ts#L56
Unfortunately, if a parent column is cached, this ends up not being run on its child columns, since `CollectionBuilder` doesn’t iterate on child nodes when `shouldInvalidate` returns false:
https://github.com/adobe/react-spectrum/blob/b57b3af44c345d456658e2895bb9244c65f0e7d3/packages/%40react-stately/collections/src/CollectionBuilder.ts#L98
This means that those nested columns do not get added into `context.columns`, so the check for `Row`s that they have the same number of cells as there are columns fails. (E.g. “Cell count must match column count. Found 3 cells and 0 columns.”)
I’m not sure what the right fix is around what to cache or not cache… it may be that `shouldInvalidate` should always return `true` for columns with child nodes?
## 🤔 Expected Behavior
## 😯 Current Behavior
## 💁 Possible Solution
## 🔦 Context
## 💻 Code Sample
## 🌍 Your Environment
| Software | Version(s) |
| ---------------- | ---------- |
| react-spectrum |
| Browser |
| Operating System |
## 🧢 Your Company/Team
## 🕷 Tracking Issue (optional)
Contributor guide
Assessment
This issue has not been assessed yet.