Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Table 的 Columns 设置成 align: "right" 跟 sorter 排序一起使用时 表头显示跟align: "right" 不符 #1599

Closed
1 task done
geekerio opened this issue May 9, 2023 · 3 comments · Fixed by #1614
Assignees
Labels
bug Something isn't working

Comments

@geekerio
Copy link

geekerio commented May 9, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Which Component

Table

Semi Version

2.34.0

Current Behavior

{
title: "大小",
dataIndex: "size",
align: "right",
sorter: (a, b) => (a.size - b.size > 0 ? 1 : -1),
render: (text) => ${text} KB
},

当我给 Columns加上 align: "right", 跟 sorter: (a, b) => (a.size - b.size > 0 ? 1 : -1) 一起使用时出现表头对齐出现问题 tr 是右对齐, th 还是左对齐

image

Expected Behavior

表头th 跟 tr 都应该是需要 按 Columns 的 align 方式来对齐

Steps To Reproduce

No response

ReproducibleCode

https://codesandbox.io/s/cool-dream-rqid7m


const columns = [
    {
        title: '标题',
        dataIndex: 'name',
        width: 120,
        render: (text, record, index) => {
            return (
                <div>
                    <Avatar size="small" shape="square" src={figmaIconUrl} style={{ marginRight: 12 }}></Avatar>
                    {text}
                </div>
            );
        },
        filters: [
            {
                text: 'Semi Design 设计稿',
                value: 'Semi Design 设计稿',
            },
            {
                text: 'Semi Pro 设计稿',
                value: 'Semi Pro 设计稿',
            },
        ],
        onFilter: (value, record) => record.name.includes(value),
        sorter: (a, b) => (a.name.length - b.name.length > 0 ? 1 : -1),
    },
    {
        title: '大小',
        dataIndex: 'size',
        align: "right",
        sorter: (a, b) => (a.size - b.size > 0 ? 1 : -1),
        render: text => `${text} KB`,
    },
    {
        title: '所有者',
        align: "right",
        dataIndex: 'owner',
        render: (text, record, index) => {
            return (
                <div>
                    <Avatar size="small" color={record.avatarBg} style={{ marginRight: 4 }}>
                        {typeof text === 'string' && text.slice(0, 1)}
                    </Avatar>
                    {text}
                </div>
            );
        },
    },
    {
        title: '更新日期',
        align: "right",
        dataIndex: 'updateTime',
        sorter: (a, b) => (a.updateTime - b.updateTime > 0 ? 1 : -1),
        render: value => {
            return dateFns.format(new Date(value), 'yyyy-MM-dd');
        },
    },
];

return (
    <div className="App">
      <Table
        columns={columns}
        dataSource={dataSource}
        rowSelection={rowSelection}
        scroll={scroll}
      />
      ;
    </div>
  );

Environment

- OS:
- browser:

Anything else?

No response

@shijiatongxue shijiatongxue self-assigned this May 11, 2023
@shijiatongxue shijiatongxue added the bug Something isn't working label May 11, 2023
@shijiatongxue
Copy link
Collaborator

好的,我们排查一下~

@shijiatongxue
Copy link
Collaborator

https://codesandbox.io/s/cool-dream-rqid7m

应该是这个版本引入的 bug。

image

shijiatongxue pushed a commit that referenced this issue May 19, 2023
pointhalo pushed a commit that referenced this issue May 19, 2023
Co-authored-by: shijia.me <shijia.me@bytedance.com>
@shijiatongxue
Copy link
Collaborator

2.36.0-beta.0 fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants