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

pagination点击下一页后按下Enter键页数会加二 #47531

Open
selicens opened this issue Feb 21, 2024 · 1 comment · May be fixed by react-component/pagination#562
Open

pagination点击下一页后按下Enter键页数会加二 #47531

selicens opened this issue Feb 21, 2024 · 1 comment · May be fixed by react-component/pagination#562

Comments

@selicens
Copy link
Contributor

Reproduction link

https://ant-design.gitee.io/components/pagination-cn

Steps to reproduce

  1. pagination组件官网demo,点击下一页
  2. 按下Enter键

What is expected?

页数加一

What is actually happening?

页数加二

Environment Info
antd 5.14.1
React ^18.2.0
System Windows11
Browser Edge121.0.2277.128

rc-pagination#562
当点击下一页后按下enter键,预期是出现页数加一,但实际按下enter键除了会触发键盘事件还会默认触发元素的点击事件,所以会出现页数加二的情况,反之点击上一页然后按下enter键也是如此,页数会减二而不是预期的减一,最直接的解决办法是event.preventDefault阻止默认事件即可,但是也会想到即使不写键盘事件,点击下一页,此时元素已经获取到焦点,此时按下enter键也会默认触发元素的点击事件,达到页数加一的效果,那么写键盘事件是否是冗余代码?翻看了业内比较知名的mui与element-plus,似乎他们并没有专门关照enter键盘事件

@wsxe9988
Copy link

@afc163 @zombieJ

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

Successfully merging a pull request may close this issue.

2 participants