Skip to content

fix: change pageSize not call onChange #272

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

Merged
merged 4 commits into from
Jun 12, 2020

Conversation

fireairforce
Copy link
Contributor

@codecov
Copy link

codecov bot commented May 29, 2020

Codecov Report

Merging #272 into master will increase coverage by 0.36%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #272      +/-   ##
==========================================
+ Coverage   90.96%   91.33%   +0.36%     
==========================================
  Files           3        3              
  Lines         321      323       +2     
  Branches      111      112       +1     
==========================================
+ Hits          292      295       +3     
+ Misses         29       28       -1     
Impacted Files Coverage Δ
src/Pagination.jsx 90.90% <100.00%> (+0.47%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9257d8d...fa0a7d3. Read the comment docs.

@yoyo837
Copy link
Member

yoyo837 commented May 29, 2020

it's a break change. 其他组件封装有pagination的都自行触发的onChange. 如果接受此PR,其他组件可能涉及到调整。 ant-design/ant-design#24514 (comment)

@fireairforce
Copy link
Contributor Author

fireairforce commented May 29, 2020

我看了下table组件那边切pageSize的时候onChange也没有被调用,就做出了这样的修改。。
https://codesandbox.io/s/kebianjixing-ant-design-demo-e6yz6

@yoyo837
Copy link
Member

yoyo837 commented May 29, 2020

antd/components/table/hooks/usePagination.ts 就是我说的这种情况

@fireairforce
Copy link
Contributor Author

我这里先还是先针对 List 那边做一下改动把~

@yoyo837
Copy link
Member

yoyo837 commented Jun 2, 2020

别急嘛,ping 大佬来做决定

@yoyo837 yoyo837 requested review from afc163 and zombieJ June 2, 2020 11:03
@fireairforce
Copy link
Contributor Author

嘿嘿嘿 好的

@afc163
Copy link
Member

afc163 commented Jun 2, 2020

什么决定,谁来总结一下现状。

@yoyo837
Copy link
Member

yoyo837 commented Jun 2, 2020

分页组件自己onSizeChange不会触发onChange,antd那边组合使用分页组件的组件自行触发的onChange,但是你在上面引用的antd的issue中说onSizeChange应该触发onChange,不知道指的是分页组件本身还是组合了分页组件的组件

@fireairforce
Copy link
Contributor Author

我现在觉得改这里有点激进了 = = ,不如就先在List 那边调整一下。。。

@zombieJ
Copy link
Member

zombieJ commented Jun 3, 2020

onChange 里有 pageSize 参数,那看起来的确是应该触发才对。

代码里直接判断 onChange 存不存在,in 会存在 onChange={null} 报错的情况。另外,也需要测试用例,防止重复触发的情况。

@fireairforce
Copy link
Contributor Author

可以,我update一下

@fireairforce
Copy link
Contributor Author

onChange 里有 pageSize 参数,那看起来的确是应该触发才对。

代码里直接判断 onChange 存不存在,in 会存在 onChange={null} 报错的情况。另外,也需要测试用例,防止重复触发的情况。

这里重复触发的场景是?不过 @yoyo837 说的情况可能确实会存在,因为这个rc-pagination组件自身的onShowSizeChange是不会去触发onChange的,但是有些用了这个组件的组件例如Tabel,List这些可能是会在自己组件那边改变pageSize去触发 onChange的。。。这里还得看看怎么调整~

@yoyo837
Copy link
Member

yoyo837 commented Jun 3, 2020

onChange 里有 pageSize 参数,那看起来的确是应该触发才对。
代码里直接判断 onChange 存不存在,in 会存在 onChange={null} 报错的情况。另外,也需要测试用例,防止重复触发的情况。

这里重复触发的场景是?不过 @yoyo837 说的情况可能确实会存在,因为这个rc-pagination组件自身的onShowSizeChange是不会去触发onChange的,但是有些用了这个组件的组件例如Tabel,List这些可能是会在自己组件那边改变pageSize去触发 onChange的。。。这里还得看看怎么调整~

豆酱没裁断我说的这个情况怎么改,该不该改!

@fireairforce
Copy link
Contributor Author

嗯,我怕他没理解,所以解释一下~

@zombieJ
Copy link
Member

zombieJ commented Jun 3, 2020

我的观点是如果 onChange 中暴露了 pageSize 那就需要触发,没有的话就不应该,因为用户角度看起来触发两次 onChange 是没有变化的。这个 Pagination 我认为应该触发也是因为它有一个 pageSize 参数

@yoyo837
Copy link
Member

yoyo837 commented Jun 3, 2020

那 那些组合了分页组件的其他组件 也需要修改了,因为它们自行触发了onChange。感觉涉及范围有点广。

@fireairforce
Copy link
Contributor Author

ant-design/ant-design#24514 (comment) afc163 大佬表示暂时先改List组件那边吧。

@afc163
Copy link
Member

afc163 commented Jun 11, 2020

来个用例。

@zombieJ
Copy link
Member

zombieJ commented Jun 11, 2020

改完发个 minor

@fireairforce
Copy link
Contributor Author

ok~那我加个case吧

@fireairforce
Copy link
Contributor Author

done~

@yoyo837
Copy link
Member

yoyo837 commented Jun 12, 2020

antd引用minor版本这三个地方可能需要跟随调整

image

@fireairforce
Copy link
Contributor Author

我晚上调整一下吧

@yoyo837
Copy link
Member

yoyo837 commented Jun 12, 2020

我晚上调整一下吧

你得等到这个得合并,发布大版本后,在antd引入新版本,然后一并一个PR修改

@fireairforce
Copy link
Contributor Author

ok~

@afc163 afc163 merged commit d426196 into react-component:master Jun 12, 2020
@afc163
Copy link
Member

afc163 commented Jun 12, 2020

2.3.0

@fireairforce
Copy link
Contributor Author

我在feature上开个pr把这个升级和修改了吧。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants