mirror of
https://github.com/we-promise/sure.git
synced 2026-04-09 07:14:47 +00:00
Fix French decimal separator handling in money input fields
Number.parseFloat() only recognizes dots as decimal separators, causing inputs like "256,54" (French locale) to be parsed as "256". Added a parseLocaleFloat utility that detects whether comma or dot is the decimal separator and normalizes accordingly before parsing. Fixes #1138 https://claude.ai/code/session_01ThfszjiCmbDDPyb4TZqk2X
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import parseLocaleFloat from "utils/parse_locale_float"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["customWrapper", "customField", "tickerSelect", "qtyField", "priceField", "priceWarning", "priceWarningMessage"]
|
||||
@@ -42,8 +43,8 @@ export default class extends Controller {
|
||||
|
||||
// Calculate the implied/entered price
|
||||
let enteredPriceCents = null
|
||||
const qty = Number.parseFloat(this.qtyFieldTarget?.value)
|
||||
const enteredPrice = Number.parseFloat(this.priceFieldTarget?.value)
|
||||
const qty = parseLocaleFloat(this.qtyFieldTarget?.value)
|
||||
const enteredPrice = parseLocaleFloat(this.priceFieldTarget?.value)
|
||||
|
||||
if (enteredPrice && enteredPrice > 0) {
|
||||
// User entered a price directly
|
||||
|
||||
Reference in New Issue
Block a user