- Operating System: 10.12.6
- Cypress Version: 1.1.1
- Browser Version: n/a
Is this a Feature or Bug?
A bug.
Current behavior:
Calling .clear() on an input with a maxlength attribute smaller than 16 outputs odd characters in the field instead of clearing it.
Desired behavior:
Calling .clear() on an input with a maxlength attribute smaller than 16 clears the field.
How to reproduce:
Test code:
cy.get('input[maxlength]').clear()
Additional Info (images, stack traces, etc)
This bug was introduced in 1.1.1 with #930 as mentioned in this comment.
Calling .clear() seems to call .type() with {selectall}{del} as per the following snippet. This string is 16 characters long and takes into account the maxlength attribute (while it should not).
|
cy.now("type", $el, "{selectall}{del}", { |
The changes introduced in 1.1.1 slice the characters to respect the maxlength attribute value, therefore slicing these tokens. This is why a maxlength from 1 to 15 causes this bug.
I guess not counting tokens in the characters count is probably the way to go. Pseudo code could look like:
const tokens = RegExp(Object.keys(keyStandardMap).join('|'), 'g')
chars.replace(tokens, '')
Is this a Feature or Bug?
A bug.
Current behavior:
Calling
.clear()on an input with amaxlengthattribute smaller than 16 outputs odd characters in the field instead of clearing it.Desired behavior:
Calling
.clear()on an input with amaxlengthattribute smaller than 16 clears the field.How to reproduce:
Test code:
Additional Info (images, stack traces, etc)
This bug was introduced in 1.1.1 with #930 as mentioned in this comment.
Calling
.clear()seems to call.type()with{selectall}{del}as per the following snippet. This string is 16 characters long and takes into account themaxlengthattribute (while it should not).cypress/packages/driver/src/cy/commands/actions/type.coffee
Line 402 in cb67a5a
The changes introduced in 1.1.1 slice the characters to respect the
maxlengthattribute value, therefore slicing these tokens. This is why a maxlength from 1 to 15 causes this bug.I guess not counting tokens in the characters count is probably the way to go. Pseudo code could look like: