Skip to content

Commit

Permalink
* dtable: fix childLabel not work with negative parent value.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed May 20, 2024
1 parent b92ec37 commit 53932fb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/dtable/src/plugins/nested/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,17 @@ const nestedPlugin: DTablePlugin<DTableNestedTypes, DTableNestedDependencies> =
const {id: rowID, data: rowData} = row;
const {nestedToggle, childLabel} = col.setting;
const info = this.getNestedRowInfo(rowID);
if (rowData![this.options.nestedParentKey || 'parent'] && childLabel) {
let labelView: ComponentChildren;
if (typeof childLabel === 'string') {
labelView = <span className="dtable-child-label label rounded-full size-sm gray-pale">{formatString(childLabel, rowData)}</span>;
} else {
labelView = <CustomContent className="dtable-child-label" content={childLabel} generatorThis={cellInfo} />;
if (childLabel) {
const parent = Number(rowData![this.options.nestedParentKey || 'parent']);
if (!Number.isNaN(parent) && parent > 0) {
let labelView: ComponentChildren;
if (typeof childLabel === 'string') {
labelView = <span className="dtable-child-label label rounded-full size-sm gray-pale">{formatString(childLabel, rowData)}</span>;
} else {
labelView = <CustomContent className="dtable-child-label" content={childLabel} generatorThis={cellInfo} />;
}
result.unshift(labelView);
}
result.unshift(labelView);
}
if (nestedToggle && (info.children || info.parent)) {
result.push(
Expand Down

0 comments on commit 53932fb

Please sign in to comment.