Skip to content

Commit

Permalink
web-forms (Vue UI fix): allow decimal input on Safari/iOS
Browse files Browse the repository at this point in the history
This pretty much settles the matter in my mind: unless PrimeVue 4’s equivalent component is vastly better, we should look into other options. This should be either the default behavior, or the default when anything decimal is implicated.
  • Loading branch information
eyelidlessness committed Dec 13, 2024
1 parent 4fc57fb commit 4cdc794
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,24 @@ interface FractionalDigitOptions {
readonly max?: number;
}
let fractionalDigits: FractionalDigitOptions = {};
let fractionalDigits: FractionalDigitOptions;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode}
*/
type NumericInputMode = 'decimal' | 'numeric';
let inputMode: NumericInputMode;
if (props.isDecimal) {
fractionalDigits = {
min: 0,
max: 18,
};
inputMode = 'decimal';
} else {
fractionalDigits = {};
inputMode = 'numeric';
}
/**
Expand Down Expand Up @@ -149,6 +160,11 @@ const onInput = (event: InputNumberInputEvent) => {
:min-fraction-digits="fractionalDigits.min"
:max-fraction-digits="fractionalDigits.max"
:use-grouping="node.appearances['thousands-sep']"
:pt="{
input: {
root: { inputMode }
}
}"
@input="onInput"
@blur="doneAnswering = true"
/>
Expand Down

0 comments on commit 4cdc794

Please sign in to comment.