Skip to content

Commit

Permalink
fix(datatable): selection function not working as expected (carbon-de…
Browse files Browse the repository at this point in the history
…sign-system#11449)

### Related Ticket(s)

Closes carbon-design-system#11349

### Description

To use Selection on DataTable, the documentation states that just need to add the `is-selectable` property in the cds-table tag and setting the prop will automatically set a numerical `selection-name` attribute to every row. This does not happen.

### Changelog

**Changed**

- Updated the selection functionality to check if `is-selectable` property set to the DataTable, and if so to add `selection-name` property to the rows.

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "test: e2e": Codesandbox examples and e2e integration tests -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
  • Loading branch information
sangeethababu9223 authored and m4olivei committed Feb 1, 2024
1 parent f004e82 commit 9e51cc6
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,12 @@ class CDSTable extends HostListenerMixin(LitElement) {
}

if (changedProperties.has('isSelectable')) {
this._tableHeaderRow.setAttribute('selection-name', 'header');
this._tableRows.forEach((e, index) => {
if (!e.hasAttribute('selection-name')) {
e.setAttribute('selection-name', index);
}
});
this.headerCount++;
}

Expand Down

0 comments on commit 9e51cc6

Please sign in to comment.