Skip to content

Commit 4509db3

Browse files
fix: properly handle 0 as row ID (#9087)
Co-authored-by: Robert Snow <rsnow@adobe.com>
1 parent a0d9474 commit 4509db3

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

packages/@react-aria/collections/src/CollectionBuilder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ const CollectionContext = createContext<CachedChildrenOptions<unknown> | null>(n
221221
export function Collection<T extends object>(props: CollectionProps<T>): JSX.Element {
222222
let ctx = useContext(CollectionContext)!;
223223
let dependencies = (ctx?.dependencies || []).concat(props.dependencies);
224-
let idScope = props.idScope || ctx?.idScope;
224+
let idScope = props.idScope ?? ctx?.idScope;
225225
let children = useCollectionChildren({
226226
...props,
227227
idScope,

packages/@react-aria/collections/src/useCachedChildren.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function useCachedChildren<T extends object>(props: CachedChildrenOptions
5050
throw new Error('Could not determine key for item');
5151
}
5252

53-
if (idScope) {
53+
if (idScope != null) {
5454
key = idScope + ':' + key;
5555
}
5656
// Note: only works if wrapped Item passes through id...

packages/react-aria-components/stories/Table.stories.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ let columns = [
212212
];
213213

214214
let rows = [
215-
{id: 1, name: 'Games', date: '6/7/2020', type: 'File folder'},
216-
{id: 2, name: 'Program Files', date: '4/7/2021', type: 'File folder'},
217-
{id: 3, name: 'bootmgr', date: '11/20/2010', type: 'System file'},
218-
{id: 4, name: 'log.txt', date: '1/18/20167', type: 'Text Document'}
215+
{id: 0, name: 'Games', date: '6/7/2020', type: 'File folder'},
216+
{id: 1, name: 'Program Files', date: '4/7/2021', type: 'File folder'},
217+
{id: 2, name: 'bootmgr', date: '11/20/2010', type: 'System file'},
218+
{id: 3, name: 'log.txt', date: '1/18/20167', type: 'Text Document'}
219219
];
220220

221221
export const TableDynamicExample: TableStory = () => {
@@ -228,7 +228,7 @@ export const TableDynamicExample: TableStory = () => {
228228
</TableHeader>
229229
<TableBody items={rows}>
230230
{(item) => (
231-
<Row columns={columns}>
231+
<Row columns={columns} id={item.id}>
232232
{(column) => {
233233
return <Cell>{item[column.id]}</Cell>;
234234
}}

0 commit comments

Comments
 (0)