Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 811c21e

Browse files
myan9starpit
authored andcommitted
fix(plugins/plugin-client-commong): show RadioTable selected row in the table body and header breadcrumb
Fixes #5239
1 parent e2ed7d8 commit 811c21e

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

plugins/plugin-client-common/src/components/spi/RadioTable/impl/Carbon.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,18 +91,18 @@ export default class CarbonRadioTable extends React.PureComponent<Props, State>
9191
breadcrumbs.push({ label: strings('nRows', table.body.length) })
9292
}
9393

94-
return <Toolbar className="kui--data-table-toolbar-top" breadcrumbs={breadcrumbs.length > 0 && breadcrumbs} />
95-
}
96-
97-
private bottomToolbar() {
9894
if (this.props.selectedIdx >= 0) {
9995
const selectedRow = this.props.table.body[this.props.selectedIdx]
100-
return <Toolbar>{this.row(selectedRow, this.props.selectedIdx)}</Toolbar>
96+
if (selectedRow.nameIdx !== undefined) {
97+
breadcrumbs.push({ label: radioTableCellToString(selectedRow.cells[selectedRow.nameIdx]) })
98+
}
10199
}
100+
101+
return <Toolbar className="kui--data-table-toolbar-top" breadcrumbs={breadcrumbs.length > 0 && breadcrumbs} />
102102
}
103103

104104
private row(row: RadioTableRow, ridx: number, head = false, onSelect?: () => void) {
105-
const isSelected = !onSelect && !head && ridx === this.props.selectedIdx - this.props.offset
105+
const isSelected = !head && ridx === this.props.selectedIdx - this.props.offset
106106
const name = this.id(ridx)
107107

108108
// notes: label is needed for selection
@@ -111,7 +111,11 @@ export default class CarbonRadioTable extends React.PureComponent<Props, State>
111111
label
112112
head={head}
113113
key={ridx}
114-
className={'kui--radio-table-row' + (head ? ' kui--radio-table-row--header-row' : '')}
114+
className={
115+
'kui--radio-table-row' +
116+
(head ? ' kui--radio-table-row--header-row' : '') +
117+
(isSelected ? ' kui--inverted-color-context bx--structured-list-row--selected' : '')
118+
}
115119
data-name={row.nameIdx !== undefined ? radioTableCellToString(row.cells[row.nameIdx]) : name}
116120
data-is-selected={isSelected || undefined}
117121
>
@@ -164,9 +168,7 @@ export default class CarbonRadioTable extends React.PureComponent<Props, State>
164168
private body() {
165169
return (
166170
<StructuredListBody className="kui--radio-table-body">
167-
{this.props.table.body.map(
168-
(row, idx) => idx !== this.props.selectedIdx && this.row(row, idx, false, row.onSelect)
169-
)}
171+
{this.props.table.body.map((row, idx) => this.row(row, idx, false, row.onSelect))}
170172
</StructuredListBody>
171173
)
172174
}
@@ -177,7 +179,6 @@ export default class CarbonRadioTable extends React.PureComponent<Props, State>
177179
<div className="kui--screenshotable">
178180
<Card
179181
header={this.props.title && this.topToolbar()}
180-
footer={this.bottomToolbar()}
181182
footerClassName="kui--inverted-color-context kui--no-padding"
182183
>
183184
<div className="kui--data-table-container">

plugins/plugin-client-common/web/scss/components/RadioTable/Carbon.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
$max-body-height: 30rem;
2222
$min-body-width: 30rem;
2323

24-
[kui-theme-style] .kui--radio-table .kui--radio-table-row:hover .bx--structured-list-svg {
24+
[kui-theme-style] .kui--radio-table .kui--radio-table-row:hover:not([data-is-selected]) .bx--structured-list-svg {
2525
fill: var(--color-text-02);
2626
}
2727

plugins/plugin-client-common/web/scss/components/StructuredList/Carbon.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@
7373
}
7474
}
7575

76+
.bx--structured-list--selection
77+
.bx--structured-list-row:hover:not(.bx--structured-list-row--header-row)
78+
> .bx--structured-list-td,
79+
.bx--structured-list-row.bx--structured-list-row--selected > .bx--structured-list-td {
80+
color: inherit;
81+
}
82+
7683
.bx--structured-list--selection
7784
.bx--structured-list-row:hover:not(.bx--structured-list-row--header-row):not(.bx--structured-list-row--selected) {
7885
background-color: var(--color-ui-03);

plugins/plugin-client-common/web/scss/components/Table/tables.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,11 @@ body[kui-theme-style] .kui--data-table-wrapper {
213213
overflow: auto;
214214
}
215215
}
216+
217+
.kui--radio-table-row.kui--inverted-color-context.bx--structured-list-row--selected {
218+
background-color: var(--color-sidecar-header);
219+
}
220+
221+
[kui-theme-style='dark'] .kui--radio-table-row.kui--inverted-color-context.bx--structured-list-row--selected {
222+
background-color: var(--color-sidecar-background);
223+
}

0 commit comments

Comments
 (0)