question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The caret is always set to the far right when deleting or inserting numbers when using the `$` currency sign

See original GitHub issue

Current behavior

If user enters “$123.45” then places cursor to left of decimal (e.g. “$123|.45”), presses Backspace to delete the 3 or types a new number, the cursor moves all the way to the right. If user presses backspace again, the 5 is then deleted.

Expected behavior

If user enters $123.45 then places cursor to left of decimal (e.g. “$123|.45”), presses Backspace to delete the 3 or types a new number, the cursor should remain where it is.

Steps to reproduce the problem

  1. Use autoNumeric version 4.6.0
  2. In the browser Chrome version 81 and 83.
  3. On the Windows operating system
  4. Then instantiate the autoNumeric object with the following options:
CurrencySymbol: "$",
    decimalCharacterAlternative: ",",
    decimalPlacesRawValue: 2,
    decimalPlacesShownOnBlur: 2,
    decimalPlacesShownOnFocus: 2,
    emptyInputBehavior: "always",
    historySize: 5,
    maximumValue: "999999",
    minimumValue: "0",
    negativePositiveSignPlacement: "p",
    onInvalidPaste: "clamp",
    unformatOnSubmit: true,
    emptyInputBehavior: "zero",
    modifyValueOnWheel: false

Link to live example (ie. Codepen)

https://www.quantumpayments.com/sandbox/Practice/autoNumericExample.html

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Diamentixcommented, Aug 20, 2020

I can reproduce the bug using that code sample. So far, when using any other currency sign than $, it works as expected. I suspect a faulty regex is at play here.

I’ve found another case, where this seems to occur - right now whenever I have a negative value (I used the code sample You provided) - whether it’s $ or - the same issue occurs when I delete a digit.

Steps to reproduce:

  1. Use linked code sample
  2. Set the config to the one with (comment the $ one)
  3. Type a value
  4. Add a - into it
  5. The caret moves to the end of the value Additionally:
  6. Move caret between the digits (regardless of integer or decimals)
  7. Remove any digit (either backspace or delete)
  8. The caret once again moves to the end of the value

However an important factor is that it only occurs in select few negative value configs, namely: negativePositiveSignPlacement: "l" or negativePositiveSignPlacement: "p" The suffix and right values seem to work properly. So basically either for the $ itself or any currency symbol with a - before it - it seems to reposition the caret to the end of the input value.

0reactions
Blackbaud-TrevorBurchcommented, Oct 13, 2021

@AlexandreBonneau - I see that a fix for this was merged into the codebase on July 7. However, it does not seem that a release has been cut with this fix. Would you happen to have an ETA for when a release might happen for this fix? Thanks for any info! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

When focusing on an input having `currencySymbolPlacement ...
When focusing while using the tab key on an input having currencySymbolPlacement as p (prefix), the caret is wrongly placed on the far...
Read more >
Excel refuses to align a number left or center - YouTube
00:00 Number vs Currency vs Accounting Format - left aligned blocked00:15 Accounting format not aligning middle 00:25 Fix Accounting Format ...
Read more >
Custom Excel number format - Ablebits
This tutorial explains the basics of the Excel number format and provides the detailed guidance to create custom formatting.
Read more >
DOLLAR function - Microsoft Support
The DOLLAR function, one of the TEXT functions, converts a number to text using currency format, with the decimals rounded to the number...
Read more >
Easy Number and Currency Formatting Library - autoNumeric
autoNumeric is a useful JavaScript library for international currency formatting as well as numbers formatting.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found