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

userEvent.type does not respect maxlength when appending to existing text #281

Closed
9still opened this issue May 16, 2020 · 3 comments · Fixed by #283
Closed

userEvent.type does not respect maxlength when appending to existing text #281

9still opened this issue May 16, 2020 · 3 comments · Fixed by #283
Labels

Comments

@9still
Copy link
Contributor

9still commented May 16, 2020

When 1e8d140 introduced a change to the way .type() behaves, it did not update maxLength handling to take previous text into account.

As a result, if you have an element like this:

<textarea aria-label="input" rows="3" maxlength="10" />

doing the following

const inputField = screen.getByLabelText('input');
await userEvent.type(inputField, '123456');
await userEvent.type(inputField, '123456789101112');
screen.debug();

ends up producing:

<textarea aria-label="input" maxlength="10" rows="3" >
    1234561234567891
</textarea>

rather than what you would expect from the browser, namely:

<textarea aria-label="input" maxlength="10" rows="3" >
    1234561234
</textarea>
@kentcdodds
Copy link
Member

Thanks for the report. Would you be interested in fixing that?

@9still
Copy link
Contributor Author

9still commented May 17, 2020

@kentcdodds sure - took a stab at it. Thanks!

@Gpx
Copy link
Member

Gpx commented May 17, 2020

🎉 This issue has been resolved in version 10.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Gpx Gpx added the released label May 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants