Skip to content

Commit

Permalink
fix(layout): slove DensityIcon setting not work (ant-design#7942)
Browse files Browse the repository at this point in the history
  • Loading branch information
ONLY-yours authored Dec 6, 2023
1 parent e16d2ec commit f51ee6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions packages/table/src/components/ToolBar/DensityIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { TableContext } from '../../Store/Provide';

export type DensitySize = 'middle' | 'small' | 'large' | undefined;

const DensityIcon = () => {
const DensityIcon = (props: { icon?: React.ReactNode }) => {
const { icon = <ColumnHeightOutlined /> } = props;
const counter = useContext(TableContext);
const intl = useIntl();
const props = menuOverlayCompatible({
const dropdownProps = menuOverlayCompatible({
selectedKeys: [counter.tableSize as string],
onClick: ({ key }) => {
counter.setTableSize?.(key as DensitySize);
Expand All @@ -33,10 +34,13 @@ const DensityIcon = () => {
},
],
});

console.log('props', props);

return (
<Dropdown {...props} trigger={['click']}>
<Dropdown {...dropdownProps} trigger={['click']}>
<Tooltip title={intl.getMessage('tableToolBar.density', '表格密度')}>
<ColumnHeightOutlined />
{icon}
</Tooltip>
</Dropdown>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/table/src/components/ToolBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function getButtonText(
},
density: {
text: intl.getMessage('tableToolBar.density', '表格密度'),
icon: options.densityIcon ?? <DensityIcon />,
icon: <DensityIcon icon={options.densityIcon} />,
},
fullScreen: {
text: intl.getMessage('tableToolBar.fullScreen', '全屏'),
Expand Down

0 comments on commit f51ee6a

Please sign in to comment.