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

Digits Scrambled when using type on tel input field with input mask #940

Closed
calvinballing opened this issue Nov 20, 2017 · 14 comments · Fixed by #2016
Closed

Digits Scrambled when using type on tel input field with input mask #940

calvinballing opened this issue Nov 20, 2017 · 14 comments · Fixed by #2016
Assignees
Labels
pkg/driver This is due to an issue in the packages/driver directory type: bug
Milestone

Comments

@calvinballing
Copy link
Contributor

  • Operating System: Windows 10
  • Cypress Version: 1.1.0
  • Browser Version: Chrome

Is this a Feature or Bug?

Bug

Current behavior:

When using .type() on tel inputs with masks, the numbers are entered out of order. That is, digits are added to the end of the field when they meet a special character.

Desired behavior:

The digits are entered into the field in order.

How to reproduce:

Call .type() on a tel input field with an input mask that provides hyphens, parentheses, or other formatting

Test code:

cy.get("#PrimaryPhone").type("1234567890").should('have.value', "(123) 456-7890")
//The above expected output is based on the input mask used by my application.  
//Your mileage may vary.

Additional Info (images, stack traces, etc)

@jennifer-shehane jennifer-shehane added the pkg/driver This is due to an issue in the packages/driver directory label Nov 21, 2017
@jennifer-shehane
Copy link
Member

jennifer-shehane commented Nov 21, 2017

Can confirm, fails in v1.1.1. To replicate:

Test code

it('Type in tel input with input mask', function(){
  cy.visit('http://robinherbots.github.io/Inputmask/')
  cy.contains('Demo').click()
  cy.get('input[data-inputmask-alias]').first()
    .type('11212017')
    .should('have.value', '11/21/2017')
})

Failed message
screen shot 2017-11-21 at 9 17 47 am

@jennifer-shehane jennifer-shehane added stage: ready for work The issue is reproducible and in scope type: bug labels Nov 21, 2017
@lardissone
Copy link

Also doesn't works with text-mask.

@lardissone
Copy link

Typing the complete value works with text-mask.

For example I have a mask for times like: 10:30 am and if I type it literally .type('10:30 am') it works.

@jennifer-shehane jennifer-shehane added the good first issue Good for newcomers label Nov 27, 2017
@John758364
Copy link

John758364 commented Nov 27, 2017

I have something similar

Steps to reproduce

Run this on localhost:8000

<html>

<head>
</head>

<body>
    <input id="billingZip" name="zip" type="tel" value="55344" placeholder="" maxlength="5" data-track-id="" class="sessioncamhidetext form-control   ">
</body>

</html>

Run the following tests

Test code:

it('Not Working Example', () => {
    cy.visit('localhost:8000')
    cy.get('#billingZip').clear().type('54321')
});

it('Workaround Example', () => {
    cy.visit('localhost:8000')
    cy.get('#billingZip').invoke('attr', 'maxlength', '10').clear().type('54321')
});

@brian-mann
Copy link
Member

brian-mann commented Nov 27, 2017

@JPHamlett1993 actually after looking at your code I think you're referring to a bug in 1.1.1 that we've fixed and released in 1.1.2.

Update to that and it should work.

https://docs.cypress.io/guides/references/changelog.html#1-1-2

@John758364
Copy link

@brian-mann I am on 1.1.2

@brian-mann
Copy link
Member

@JPHamlett1993 I confirmed your issue. I think it's a separate one from this. It's another edge case around the maxlength. Basically what's happening is that your input is already at maxlength, and then cypress is not applying the special character because it thinks it's been exceeded.

@John758364
Copy link

@brian-mann Why does Cypress look at max-length, why shouldn't the application handle that?

@brian-mann
Copy link
Member

Because maxlength is irrelevent when setting the value property directly

@davidszepernick
Copy link

I have an element as follows:

cy.get('#auth_column').clear() does not work for this field
( I dont think any of the special character sequences are working either.)

@davidszepernick
Copy link

sorry, as follows:
input type="text" name="auth_column" id="auth_column" value="AB" maxlength="2" minlength="2" class="av-touched av-pristine av-valid form-control"

@jennifer-shehane jennifer-shehane added Epic Requires breaking up into smaller issues and removed Epic Requires breaking up into smaller issues labels Jan 31, 2018
@paulbao
Copy link

paulbao commented May 2, 2018

There's workaround that might be helpful to people who have the same issue.
cy.get("#PrimaryPhone").then($input => $input.val('(123) 456-7890')).should('have.value', "(123) 456-7890")

update

It seems that this won't actually change the input value when it lost focus. I've tried sth like $input.attr('value', '(123) 456-7890') but not working for me.

@LeightonDarkins
Copy link

@paulbao Extending on your workaround, I found that overriding the value worked great, but I still needed to call .type() to trigger an onChange event.

So I chose to simulate clear() by emptying the input value, then typing in the new value I wanted:

    cy.get('#UserInfoDialog input')
      .then($input => $input.val(''))
      .type('123')
      .should('have.value', '123')

@kuceb
Copy link
Contributor

kuceb commented Jun 29, 2018

I'm currently working on this. An upcoming patch release should fix this issue - this should be true for many cy.type related bugs

@kuceb kuceb added this to the 3.0.3 milestone Jun 29, 2018
@kuceb kuceb self-assigned this Jun 29, 2018
@kuceb kuceb removed the good first issue Good for newcomers label Jun 29, 2018
@kuceb kuceb added pkg/driver This is due to an issue in the packages/driver directory and removed pkg/driver This is due to an issue in the packages/driver directory stage: ready for work The issue is reproducible and in scope labels Jul 16, 2018
brian-mann pushed a commit that referenced this issue Jul 23, 2018
this grew to a large PR fixing many cy.type issues.

fix #365
fix #420
fix #586 
fix #593 
fix #596 
fix #610 
fix #651
fix #940
fix #1002 
fix #1108
fix #1171
fix #1209 
fix #1234 
fix #1366
fix #1381 
fix #1684 
fix #1686
fix #1926 
fix #2056
fix #2096 
fix #2110 
fix #2173
fix #2187
@jennifer-shehane jennifer-shehane added stage: pending release and removed stage: needs review The PR code is done & tested, needs review stage: needs investigating Someone from Cypress needs to look at this stage: in progress labels Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg/driver This is due to an issue in the packages/driver directory type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants