Skip to content

NumericInput drops the sign of negative numbers in sv-SE and other locales that use U+2212 #8276

Description

@mkzung

Environment

  • Package version(s): @blueprintjs/core 6.20.0 (develop at f73386b)
  • Operating System: macOS
  • Browser name and version: any. (-1.5).toLocaleString("sv-SE") returns "−1,5", starting with U+2212 MINUS SIGN, in Node 25 and in JavaScriptCore.

Code Sandbox

No sandbox. <NumericInput locale="sv-SE" onValueChange={console.log} /> on its own reproduces it.

Steps to reproduce

  1. Render <NumericInput locale="sv-SE" /> with no value.
  2. Click the decrement button three times.
  3. Clear the field and paste −1,5, written with U+2212.

Actual behavior

The field shows 1, then 0, then 1, so the value never goes below zero. The paste gives 1,5 and onValueChange gets 1.5.

In these locales Intl writes negatives with U+2212 instead of -. sanitizeNumericInput keeps only the characters of a floating-point number, so the sign is stripped. Five other locales, among them fi-FI and nb-NO, format negatives the same way.

Expected behavior

-1, -2, -3, and -1,5 for the paste, as with de-DE.

Possible solution

Map U+2212 to - in sanitizeNumericInput, next to the full-width digit conversion. I have a branch with that and two tests and can open a PR.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions