should type be constrained by maxLength?
See original GitHub issueIs maxLength
an attribute user-event
should take into account?
If so, the following test should pass:
// __tests__/vue/type.js
test("maxlength", () => {
const input = jest.fn();
const maxlength = 10;
const { getByTestId } = renderComponent('input',
{ input },
{ maxlength }
);
const text = "Hello, world!";
userEvent.type(getByTestId("input"), text);
expect(input).toHaveBeenCalledTimes(maxlength);
expect(getByTestId("input")).toHaveProperty("value", text.slice(0, maxlength));
});
I’ll be happy to implement it if you think it makes sense.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
HTML attribute: maxlength - MDN Web Docs
The maxlength attribute defines the maximum number of characters (as UTF-16 code units) the user can enter into an <input> or <textarea> ....
Read more >maxlength ignored for input type="number" in Chrome
So maxlength is ignored on <input type="number"> by design. Depending on your needs, you can use the min and max attributes as inon...
Read more >maxlength Constraint Validation Oddities in Major Browsers
Constraint validation is an HTML5 spec that provides native client side form validation in the browser. As part of its API, all <input>...
Read more >maxlength constraint for text box` | SAP Community
hi, I want to make a textbox to accept only 2 digits.. if i give maxlength="2" its not working..how will i acheive this?...
Read more >GraphQL validation using directives
@constraint(pattern: "^[0-9a-zA-Z]*$", maxLength: 255) } type Mutation { signUp(input: SignUpInput!) } Before we move on, it's good to mention ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like the browser doesn’t fire the events if the max length is reached: link. Since
user-event
is the one responsible for firing events I think the check should happen on our side rather than with JSDOM.What do you think?
Sounds good to me. I can work on something tomorrow at work