fix: use inputmode="decimal" for Float, Currency, and Percent fields

ControlFloat inherits from ControlInt, which sets `inputmode="numeric"`.
On mobile devices, this brings up a numeric keypad without a decimal point,
making it impossible to enter decimal values (e.g. 0.16, 0.18) for Float,
Currency, and Percent fields.

Fix: Override `input_mode` to `"decimal"` in ControlFloat. Per the HTML spec,
`inputmode="decimal"` instructs mobile browsers to display a numeric keypad
that includes a decimal separator. Since ControlCurrency and ControlPercent
both extend ControlFloat, they automatically inherit the fix.
This commit is contained in:
WFHP 2026-03-02 15:57:45 +08:00 committed by GitHub
parent fcc672315f
commit dd63ab9d9e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,5 @@
frappe.ui.form.ControlFloat = class ControlFloat extends frappe.ui.form.ControlInt { frappe.ui.form.ControlFloat = class ControlFloat extends frappe.ui.form.ControlInt {
static input_mode = "decimal";
parse(value) { parse(value) {
value = this.eval_expression(value); value = this.eval_expression(value);
return isNaN(parseFloat(value)) ? null : flt(value, this.get_precision()); return isNaN(parseFloat(value)) ? null : flt(value, this.get_precision());