Skip to content

[PB-7114]: feat/list custom item key via getItemId - #120

Merged
apsantiso merged 6 commits into
masterfrom
feat/PB-7114-list-get-item-id
Nov 17, 2026
Merged

apsantiso merged 6 commits into
masterfrom
feat/PB-7114-list-get-item-id

Conversation

@apsantiso

@apsantiso apsantiso commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

What

Adds an optional getItemId prop to List so consumers can choose which field identifies an item. It defaults to item.id, so existing lists keep working. The generic type no longer requires id.

Added tests for items with duplicated or missing id. Bumped to 0.1.30.

Why

drive-web is moving file identity from id to uuid, and List compared items by id internally.

@apsantiso
apsantiso marked this pull request as ready for review November 16, 2026 10:54
@apsantiso apsantiso self-assigned this Nov 16, 2026
@apsantiso
apsantiso requested a review from CandelR November 16, 2026 10:55
*/

const List = <T extends { id: number }, F extends keyof T>({
const List = <T extends { id?: number | string }, F extends keyof T>({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If T declares id as optional and no getItemId is passed, this compiles, but items without an id break selection. The default getKey returns undefined for all of them, and since undefined === undefined, every row reads as selected and every context menu opens at once. The as string | number cast hides it from the compiler. Reproduced locally. Could getItemId be required when T has no guaranteed id?

@apsantiso

Copy link
Copy Markdown
Member Author

@CandelR pushed a few changes after your approval so this works better for files without id.

A type with no id at all didn't compile, which would block removing id from files (I tested without removing the id field first so I didn't notice it), so I fixed that and added a couple of tests.

@apsantiso
apsantiso merged commit 5af949a into master Nov 17, 2026
1 check passed
@apsantiso
apsantiso deleted the feat/PB-7114-list-get-item-id branch November 17, 2026 13:46
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.

2 participants