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

InputNumber: Issue Accept Numpad Decimal when different to the region symbol #3722

Open
Pedro-Mag opened this issue Mar 9, 2023 · 2 comments
Labels
Status: Discussion Issue or pull request needs to be discussed by Core Team Type: New Feature Issue contains a new feature or new component request

Comments

@Pedro-Mag
Copy link

Describe the feature you would like to see added

Accept the Numpad Decimal key event always as decimal point input, no matter the region format defined.

Is your feature request related to a problem?

Sometimes the user has the keyboard numpad decimal key defined to a different symbol of region format selected.
When that happens, it's impossible to insert the decimal symbol by using the numpad.

Describe the solution you'd like

One solution could be to listen to the code off the event and if is equal to 'NumpadDecimal' change the char variable accordingly.

        onInputKeyPress(event) {
            if (this.readonly) {
                return;
            }

            event.preventDefault();
            let code = event.which || event.keyCode;
            let char = String.fromCharCode(code);
            if(event.code === 'NumpadDecimal' && !this.isDecimalSign(char)) {
                char = char == ',' ? '.' : ','
            }
            const isDecimalSign = this.isDecimalSign(char);
            const isMinusSign = this.isMinusSign(char);

            if ((48 <= code && code <= 57) || isMinusSign || isDecimalSign) {
                this.insert(event, char, { isDecimalSign, isMinusSign });
            }
        },

Describe alternatives you have considered

No response

Additional context

No response

@Pedro-Mag Pedro-Mag added Status: Discussion Issue or pull request needs to be discussed by Core Team Type: New Feature Issue contains a new feature or new component request labels Mar 9, 2023
@Pedro-Mag Pedro-Mag changed the title NumberInput: Issue Accept Numpad Decimal when different to the region symbol InputNumber: Issue Accept Numpad Decimal when different to the region symbol Mar 9, 2023
@omgitsarnout
Copy link

I am suffering from the same problem. Our client expects to be able to use both a dot and a comma as a decimal seperator but sadly primevue inputNumber does not support it by default.

@Haine-Thomas
Copy link

Is there an update on this subject ?
In some countries, people often use both dot and comma as a decimal separator. It would be nice to have the option to do both !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Discussion Issue or pull request needs to be discussed by Core Team Type: New Feature Issue contains a new feature or new component request
Projects
None yet
Development

No branches or pull requests

3 participants