Skip to content

Commit

Permalink
fix(Table): table tree if without children should icon type equal, close
Browse files Browse the repository at this point in the history
  • Loading branch information
weinianyang authored Jul 28, 2022
1 parent c879a52 commit 09ea83e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 32 deletions.
6 changes: 4 additions & 2 deletions src/table/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,10 @@
}
}
&-tree-placeholder {
display: inline-block;
width: 12px;
@include icon-size($table-tree-expanded-icon-size);
visibility: hidden;
// display: inline-block;
// width: 12px;
}
}

Expand Down
36 changes: 6 additions & 30 deletions src/table/tree/cell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,8 @@ export default class TreeCell extends React.Component {
};

render() {
const {
colIndex,
record,
prefix,
primaryKey,
locale,
rtl,
children,
} = this.props;
const {
openTreeRowKeys: openRowKeys,
indent,
isTree,
rowSelection,
} = this.context;
const { colIndex, record, prefix, primaryKey, locale, rtl, children } = this.props;
const { openTreeRowKeys: openRowKeys, indent, isTree, rowSelection } = this.context;
const treeArrowNodeIndex = rowSelection ? 1 : 0;
let firstCellStyle, treeArrowNode;
if (colIndex === treeArrowNodeIndex) {
Expand All @@ -65,15 +52,10 @@ export default class TreeCell extends React.Component {
[paddingType]: indent * (record.__level + 1),
};
treeArrowNode = (
<Icon
size="xs"
rtl={rtl}
className={`${prefix}table-tree-placeholder`}
/>
<Icon size="xs" rtl={rtl} className={`${prefix}table-tree-placeholder`} type="arrow-right" />
);
if (record.children && record.children.length) {
const hasExpanded =
openRowKeys.indexOf(record[primaryKey]) > -1;
const hasExpanded = openRowKeys.indexOf(record[primaryKey]) > -1;

treeArrowType = hasExpanded ? 'arrow-down' : 'arrow-right';

Expand All @@ -88,20 +70,14 @@ export default class TreeCell extends React.Component {
role="button"
tabIndex="0"
aria-expanded={hasExpanded}
aria-label={
hasExpanded ? locale.expanded : locale.folded
}
aria-label={hasExpanded ? locale.expanded : locale.folded}
/>
);
}
}
}
return (
<CellComponent
{...this.props}
innerStyle={firstCellStyle}
isIconLeft={!!treeArrowNode}
>
<CellComponent {...this.props} innerStyle={firstCellStyle} isIconLeft={!!treeArrowNode}>
{children}
{treeArrowNode}
</CellComponent>
Expand Down

0 comments on commit 09ea83e

Please sign in to comment.