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
Handle maxLength for userEvent.type #185
Handle maxLength for userEvent.type #185
Conversation
Codecov Report
@@ Coverage Diff @@
## master #185 +/- ##
==========================================
+ Coverage 97.2% 97.24% +0.03%
==========================================
Files 1 1
Lines 143 145 +2
Branches 34 35 +1
==========================================
+ Hits 139 141 +2
Misses 4 4
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Should we also check if tests are passing when allAtOnce
is false? Can't think of a reason why this would make it fail, but I'd also love to make sure it doesn't since we modified both if branches from opts.allAtOnce
.
@afontcu I also can't think of a reason why they would fail, but one can never be too cautious! I will find some time to add those tests as well, thank you |
61a1b6d
to
0aa8a64
Compare
@afontcu sorry to bother you, could this be reviewed again? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I'll let @Gpx review and merge it :)
Are we sure the browser doesn't continue to fire input events even though the maxlength is reached? We don't have to actually update the value, but we should make sure we fire all the same events the browser does. |
@kentcdodds I just tested an input with a maxlength, it looks like it only fires |
Cool. Are we still firing keyup/keydown events? |
I'm pretty sure that we should be, but I'm not sure whether it does in this PR |
@kentcdodds @calebeby that makes sense, I will update this PR so it still fires keyup/keydown events, thank you for your comments |
Hi! I arrived here because I have an input with a max-length attribute. I'm testing if input.value is equal to max-length |
Hi @carlos-cne, Yes, once this PR is updated and then merged that issue should go away. |
0aa8a64
to
cb0f5e9
Compare
@Gpx @kentcdodds I've updated this to reflect what was suggested in the comments above, let me know if there's anything else that I should cover or change 🐣 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thank you so much :)
expect(keydown).not.toHaveBeenCalled(); | ||
expect(keypress).not.toHaveBeenCalled(); | ||
expect(keyup).not.toHaveBeenCalled(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, shouldn't these all be called several times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not for allAtOnce: true
afaik
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super 👍
@all-contributors please add @klujanrosas for code and tests |
I've put up a pull request to add @klujanrosas! 🎉 |
🎉 This PR is included in version 8.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This is related to #161 .
I took the liberty to implement it. I look forward to your comments or suggestions.