File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 170170 const batchSelectedIds = writable (false );
171171 const tableRows = writable (rows);
172172
173+ // Internal ID prefix for radio buttons, checkboxes, etc.
174+ // since there may be multiple `DataTable` instances that have overlapping row ids.
175+ const id = " ccs-" + Math .random ().toString (36 );
176+
173177 // Store a copy of the original rows for filter restoration.
174178 $: originalRows = [... rows];
175179
499503 {#if ! nonSelectableRowIds .includes (row .id )}
500504 {#if radio}
501505 < RadioButton
502- name= " select-row -{row.id}"
506+ name= " {id} -{row.id}"
503507 checked= {selectedRowIds .includes (row .id )}
504508 on: change= {() => {
505509 selectedRowIds = [row .id ];
508512 / >
509513 {: else }
510514 < InlineCheckbox
511- name= " select-row -{row.id}"
515+ name= " {id} -{row.id}"
512516 checked= {selectedRowIds .includes (row .id )}
513517 on: change= {() => {
514518 if (selectedRowIds .includes (row .id )) {
Original file line number Diff line number Diff line change 44 import Accordion from " ./Accordion/Accordion.test.svelte" ;
55 import AccordionProgrammatic from " ./Accordion/Accordion.programmatic.test.svelte" ;
66 import AccordionDisabled from " ./Accordion/Accordion.disabled.test.svelte" ;
7+ import DuplicateDataTables from " ./DataTable/DuplicateDataTables.test.svelte" ;
78 import TreeView from " ./TreeView/TreeView.test.svelte" ;
89 import TreeViewHierarchy from " ./TreeView/TreeView.hierarchy.test.svelte" ;
910 import RecursiveList from " ./RecursiveList/RecursiveList.test.svelte" ;
3233 name: " AccordionDisabled" ,
3334 component: AccordionDisabled ,
3435 },
36+ {
37+ path: " /data-table" ,
38+ name: " DataTable" ,
39+ component: DuplicateDataTables ,
40+ },
3541 {
3642 path: " /recursive-list" ,
3743 name: " RecursiveList" ,
Original file line number Diff line number Diff line change 1+ <script lang =" ts" >
2+ import { DataTable } from " carbon-components-svelte" ;
3+
4+ const headers = [
5+ { key: " id" , value: " id" },
6+ { key: " contact.company" , value: " Company name" },
7+ ] as const ;
8+
9+ const rows = [
10+ { id: " 1" , contact: { company: " Company 1" } },
11+ { id: " 2" , contact: { company: " Company 2" } },
12+ ];
13+ </script >
14+
15+ <DataTable radio {headers } {rows } />
16+ <DataTable radio {headers } {rows } />
You can’t perform that action at this time.
0 commit comments