pagination icon indicating copy to clipboard operation
pagination copied to clipboard

fix: block default events for the enter key

Open selicens opened this issue 1 year ago • 6 comments

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

close https://github.com/ant-design/ant-design/issues/47531

selicens avatar Feb 21 '24 14:02 selicens

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
pagination ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 22, 2024 8:50am

vercel[bot] avatar Feb 21 '24 14:02 vercel[bot]

请添加测试用例

yoyo837 avatar Feb 22 '24 01:02 yoyo837

请添加测试用例

1708566250623 这个本身就有测试用例了,没必要再写一个吧

selicens avatar Feb 22 '24 01:02 selicens

这个用例并不cover你这个case

yoyo837 avatar Feb 22 '24 01:02 yoyo837

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (b89cb0e) 98.70% compared to head (0c9b4e7) 98.71%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #562   +/-   ##
=======================================
  Coverage   98.70%   98.71%           
=======================================
  Files           3        3           
  Lines         310      311    +1     
  Branches      137      137           
=======================================
+ Hits          306      307    +1     
  Misses          4        4           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 22 '24 02:02 codecov[bot]

这个用例并不cover你这个case

已加

selicens avatar Feb 22 '24 05:02 selicens