fix: block default events for the enter key#562
Open
selicens wants to merge 3 commits intoreact-component:masterfrom
Open
fix: block default events for the enter key#562selicens wants to merge 3 commits intoreact-component:masterfrom
selicens wants to merge 3 commits intoreact-component:masterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Member
|
请添加测试用例 |
Author
Member
|
这个用例并不cover你这个case |
Codecov ReportAll modified and coverable lines are covered by tests ✅
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 ☔ View full report in Codecov by Sentry. |
Author
已加 |
yoyo837
reviewed
Feb 22, 2024
| expect(onChange).toHaveBeenLastCalledWith(60, 10); | ||
| }); | ||
|
|
||
| it('should work for enter key', () => { |
Author
There was a problem hiding this comment.
对于单元测试能否还原按下enter键除了键盘事件执行还执行点击事件我不太确定
MadCcc
reviewed
Feb 22, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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