Skip to content

Commit

Permalink
Merge pull request #569 from sheinsight/fix-table-pagination
Browse files Browse the repository at this point in the history
fix: 修复`Table`分页的current被重置后,不能点击上一个相同页码的问题
  • Loading branch information
saint3347 authored Jul 5, 2024
2 parents 27114ca + 97b9b49 commit 9b6940a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sheinx",
"private": true,
"version": "3.2.6-beta.1",
"version": "3.2.6",
"description": "A react library developed with sheinx",
"module": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const usePagination = (props: BasePaginationProps) => {
if (pageSizeProp !== pageSize) setPageSize(pageSizeProp);
}, [pageSizeProp]);

useEffect(() => {
if (currentProp !== undefined && currentProp !== current) setCurrent(currentProp);
}, [currentProp]);

const handleChange = usePersistFn((c: number, size?: number) => {
if (c === current && size === undefined) return;
setCurrent(c);
Expand Down Expand Up @@ -48,7 +52,7 @@ const usePagination = (props: BasePaginationProps) => {
};

return {
current: currentProp !== undefined ? currentProp : current,
current,
pageSize,
total,
onChange: handleChange,
Expand Down
13 changes: 7 additions & 6 deletions packages/shineout/src/table/__doc__/changelog.cn.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
## 3.2.6-beta.1
2024-07-04
## 3.2.6
2024-07-05

### 🐞 BugFix
- 修复`Table`在bordered模式下, 浏览器缩放引起的滚动条计算偏差问题 ([#566](https://github.com/sheinsight/shineout-next/pull/566))
- 修复`Table`分页的current被重置后,不能点击上一个相同页码的问题 ([#569](https://github.com/sheinsight/shineout-next/pull/569))
- 修复`Table`在bordered模式下, 浏览器缩放引起的滚动条计算偏差问题 ([#562](https://github.com/sheinsight/shineout-next/pull/562))
- 修复`Table` 在屏幕某些缩放比例下闪烁的问题 ([#562](https://github.com/sheinsight/shineout-next/pull/562))


## 3.2.6-beta.0
2024-07-03

### 🐞 BugFix
- 修复 `Table` 在屏幕某些缩放比例下闪烁的问题 ([#562](https://github.com/sheinsight/shineout-next/pull/562))


## 3.2.2
2024-06-21
Expand Down
8 changes: 6 additions & 2 deletions packages/shineout/src/table/__example__/10-01-pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ const data: TableRowData[] = user.fetchSync(1000);

const App: React.FC = () => {
const [current, setCurrent] = useState<number>(1);
const [pageSize, setPageSize] = useState<number>(10);

const handlePageChange = (c: number) => {
setCurrent(c);
const handlePageChange = (_current: number, size?: number) => {
if(size !== undefined) setPageSize(size);
setCurrent(_current);
};

const columns: TableColumnItem[] = [
Expand Down Expand Up @@ -86,10 +88,12 @@ const App: React.FC = () => {
keygen='id'
data={data}
width={1500}
style={{maxHeight: '80vh'}}
columns={columns}
// bordered
pagination={{
current,
pageSize,
layout: ['links', 'list'],
onChange: handlePageChange,
pageSizeList: [10, 15, 20],
Expand Down

0 comments on commit 9b6940a

Please sign in to comment.