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

fix(table): fix table add resizable, turn page no save width #2575

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/table/PrimaryTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useRef, forwardRef, useImperativeHandle } from 'react';
import React, { useRef, forwardRef, useImperativeHandle, useMemo } from 'react';
import get from 'lodash/get';
import classNames from 'classnames';
import BaseTable from './BaseTable';
Expand Down Expand Up @@ -171,13 +171,15 @@ const PrimaryTable = forwardRef<PrimaryTableRef, TPrimaryTableProps>((props, ref
return arr;
};

const tColumns = (() => {
// 影响的因素有: columns、展开/收起行
const tColumns = useMemo(() => {
const cols = getColumns(columns);
if (showExpandIconColumn) {
cols.unshift(getExpandColumn());
}
return cols;
})();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [columns, showExpandIconColumn]);

Copy link
Collaborator

@chaishi chaishi Nov 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处需添加 getColumns 中的更多依赖,如: tDisplayColumns props.columnController props.showSortColumnBgColor props.sort primaryTableRef.current?.tableContentRef 等等,可能需要再仔细确认下

方便的话,验证一下列配置、表头吸顶、虚拟滚动等场景是否正常

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,我验证一下。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
外层太多影响Columns的,不好解决这个依赖的问题,要么导出个重置宽度的事件,这图里的注释掉,让用户自己处理要不要重置宽度是不是好点?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以,我试试在分页触发的时候读取保存好的宽度

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以,我试试在分页触发的时候读取保存好的宽度

那你解决了,后面把我这个PR关闭就好

const onInnerPageChange = (pageInfo: PageInfo, newData: Array<TableRowData>) => {
innerPagination.current = { ...innerPagination, ...pageInfo };
Expand Down
3 changes: 1 addition & 2 deletions src/table/_example/base.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const statusNameListMap = {

export default function TableBasic() {
const [stripe, setStripe] = useState(false);
const [bordered, setBordered] = useState(false);
const [bordered, setBordered] = useState(true);
const [hover, setHover] = useState(false);
const [tableLayout, setTableLayout] = useState(false);
const [size, setSize] = useState('medium');
Expand Down Expand Up @@ -70,7 +70,6 @@ export default function TableBasic() {
rowClassName={({ rowIndex }) => `${rowIndex}-class`}
cellEmptyContent={'-'}
resizable
bordered
// 与pagination对齐
pagination={{
defaultCurrent: 2,
Expand Down
8 changes: 4 additions & 4 deletions test/snap/__snapshots__/csr.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -191106,10 +191106,10 @@ exports[`csr snapshot test > csr test src/table/_example/base.jsx 1`] = `
>
<input
class="t-checkbox__former"
data-value="false"
data-value="true"
tabindex="-1"
type="checkbox"
value="0"
value="1"
/>
<span
class="t-checkbox__input"
Expand Down Expand Up @@ -191860,10 +191860,10 @@ exports[`csr snapshot test > csr test src/table/_example/base.jsx 1`] = `
>
<input
class="t-checkbox__former"
data-value="false"
data-value="true"
tabindex="-1"
type="checkbox"
value="0"
value="1"
/>
<span
class="t-checkbox__input"
Expand Down
2 changes: 1 addition & 1 deletion test/snap/__snapshots__/ssr.test.jsx.snap

Large diffs are not rendered by default.

Loading