Skip to content

Commit 277b3e0

Browse files
feat: DataTable component should use a "key" of data as the selection Key. (#17714)
Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com>
1 parent 2b10414 commit 277b3e0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/features/ee/teams/components/MemberList.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export default function MemberList(props: Props) {
177177

178178
// TODO (SEAN): Make Column filters a trpc query param so we can fetch serverside even if the data is not loaded
179179
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
180+
const [rowSelection, setRowSelection] = useState({});
180181

181182
const removeMemberFromCache = ({
182183
utils,
@@ -602,12 +603,15 @@ export default function MemberList(props: Props) {
602603
},
603604
state: {
604605
columnFilters,
606+
rowSelection,
605607
},
606608
onColumnFiltersChange: setColumnFilters,
609+
onRowSelectionChange: setRowSelection,
607610
getCoreRowModel: getCoreRowModel(),
608611
getFilteredRowModel: getFilteredRowModel(),
609612
getSortedRowModel: getSortedRowModel(),
610613
getFacetedUniqueValues: getFacetedUniqueValues(),
614+
getRowId: (row) => `${row.id}`,
611615
});
612616

613617
const fetchMoreOnBottomReached = useFetchMoreOnBottomReached(

packages/features/users/components/UserTable/UserListTable.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export function UserListTable() {
120120
const [state, dispatch] = useReducer(reducer, initialState);
121121
const [debouncedSearchTerm, setDebouncedSearchTerm] = useState("");
122122
const [isDownloading, setIsDownloading] = useState(false);
123+
const [rowSelection, setRowSelection] = useState({});
123124

124125
const [columnFilters, setColumnFilters] = useState<ColumnFiltersState>([]);
125126

@@ -385,12 +386,15 @@ export function UserListTable() {
385386
},
386387
state: {
387388
columnFilters,
389+
rowSelection,
388390
},
389391
onColumnFiltersChange: setColumnFilters,
390392
getCoreRowModel: getCoreRowModel(),
391393
// TODO(SEAN): We need to move filter state to the server so we can fetch more data when the filters change if theyre not in client cache
392394
getFilteredRowModel: getFilteredRowModel(),
393395
getSortedRowModel: getSortedRowModel(),
396+
onRowSelectionChange: setRowSelection,
397+
getRowId: (row) => `${row.id}`,
394398
getFacetedUniqueValues: (_, columnId) => () => {
395399
if (facetedTeamValues) {
396400
switch (columnId) {

0 commit comments

Comments
 (0)