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

🐞 - Number + postfix (with leading space) adds unnecessary spaces on paste of decimal number #1820

Open
4 of 9 tasks
mariorudloff opened this issue Nov 6, 2024 · 3 comments
Assignees
Labels
bug Something isn't working contributions welcome Architecture is clear and community can help P2 This issue has medium priority scope: kit Related to @maskito/kit

Comments

@mariorudloff
Copy link

Which package(s) are the source of the bug?

@maskito/kit

Playground Link

https://stackblitz.com/edit/bsm8fn?file=index.ts&hideExplorer=1

Description

When you use these settings to configure Maskito:

const maskitoOptions: MaskitoOptions = maskitoNumberOptionsGenerator({
  postfix: ' EUR',
  thousandSeparator: '.',
  decimalSeparator: ',',
  precision: 2,
  decimalZeroPadding: true,
  minusSign: '-',
});

Then its possible to paste extra spaces into the field between the postfix and the number.
This only happens when the field is completely empty.

Steps:

  • Load Page and see empty maskito input
    Image
  • paste 1234,12 into the input (with trailing spaces)

Expected:
Image

Saw:
Image

Maskito version

3.2.0

Which browsers have you used?

  • Chrome
  • Firefox
  • Safari
  • Edge

Which operating systems have you used?

  • macOS
  • Windows
  • Linux
  • iOS
  • Android
@mariorudloff mariorudloff added the bug Something isn't working label Nov 6, 2024
@nsbarsukov nsbarsukov added P2 This issue has medium priority scope: kit Related to @maskito/kit contributions welcome Architecture is clear and community can help labels Nov 6, 2024
@nsbarsukov nsbarsukov changed the title 🐞 - maskitoNumberOptionsGenerator - postfix in combination with precision allows to paste extra spaces 🐞 - Number + postfix (with leading space) adds unnecessary spaces on paste of decimal number Nov 6, 2024
@nsbarsukov
Copy link
Member

Prerequisites

const maskitoOptions: MaskitoOptions = maskitoNumberOptionsGenerator({
  postfix: ' EUR', // with leading space!
  precision: 2,
});

Test cases

  • Insert number with integer part only (with trailing spaces) - no bug ✅

    12        
    
  • Insert number with decimal part (with trailing spaces) - bug ❌

    1.2       
    

@nsbarsukov
Copy link
Member

For contributors – dont forget to write some Cypress tests.

Example:

it('paste value with extra leading and trailing spaces', () => {
cy.get('@input')
.paste(' 123456 ')
.should('have.value', '123 456')
.should('have.prop', 'selectionStart', '123 456'.length)
.should('have.prop', 'selectionEnd', '123 456'.length);
});

@AndreiBelokopytov
Copy link
Contributor

Hey! Can I get this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working contributions welcome Architecture is clear and community can help P2 This issue has medium priority scope: kit Related to @maskito/kit
Projects
None yet
Development

No branches or pull requests

3 participants