Skip to content

feat: group thousands in number fields with a configurable separator - #13

Merged
OmarShehe merged 2 commits into
masterfrom
feature/FIC-004
Oct 22, 2026
Merged

OmarShehe merged 2 commits into
masterfrom
feature/FIC-004

Conversation

@OmarShehe

Copy link
Copy Markdown
Owner

Summary

FormInputTextField (both overloads) gets groupThousands: Boolean = false and groupingSeparator: Char = ',', active only for type = NUMBER. FormInputPriceField gets groupingSeparator: Char = ','. Grouping is display only: the stored value stays plain ("2000000") and the decimal mark stays .. Defaults keep today's output, so nothing changes for existing callers. The separator may not be a digit or .; a bad value throws IllegalArgumentException.

Rejected: following the system locale (needs expect/actual on four targets and locale decimal marks) and grouping by default for all NUMBER fields (changes quantity/weight fields in every consuming app).

Changes

File Change
ui/utils/PriceFormat.kt ThousandsSeparatorTransformation validates the separator
ui/FormInputTextField.kt groupThousands, groupingSeparator on both overloads; a caller visualTransformation still wins
ui/FormInputPriceField.kt groupingSeparator
tests (commonTest, jvmTest) 14 new tests, written first
app/.../DemoSections.kt Demo amount field is grouped
.claude/skills/use-forminput/*.md New parameters documented

Acceptance criteria

  • NUMBER field with groupThousands = true and value 1234567 shows 1,234,567; onValueChange gives "1234567"
  • Typing 2000000 regroups after each keystroke and the cursor stays after the last digit
  • Editing a digit in the middle keeps the cursor next to the edit
  • 1234567.891 shows 1,234,567.891
  • groupingSeparator = ' ' shows 1 234 567 on price and number fields
  • '.' or a digit as separator throws IllegalArgumentException
  • groupThousands = true on a non-NUMBER field leaves the text unchanged
  • Defaults render exactly as before
  • A caller-supplied visualTransformation wins over grouping
  • Short, empty and leading-dot values get no stray separator
  • Price field still groups while typing and the currency selector works

Test plan

  • ./gradlew :forminput:jvmTest :forminput:compileAndroidMain -Pkotlin.native.ignoreDisabledTargets=true --rerun-tasks (218 tests, 0 failures)
  • ./gradlew :app:compileDebugKotlin
  • On a device: typed 2000000 digit by digit, inserted and deleted mid-number, 13 digits in one call, letters rejected, rotation, background/return, font scale 1.6, no crashes in logcat. The price field was not driven on the device; the automated tests cover it.

FormInputTextField gets groupThousands and groupingSeparator for NUMBER
fields, and FormInputPriceField gets groupingSeparator. Grouping is display
only, so the stored value stays plain, and both options default to today's
behaviour. The separator may not be a digit or a dot.
Document the new parameters on the TextFieldValue overload, remember the
price field's transformation like the text field does, and test that the
cursor stays next to the typed digit in a grouped field.
@OmarShehe
OmarShehe merged commit d786113 into master Oct 22, 2026
2 checks passed
@OmarShehe
OmarShehe deleted the feature/FIC-004 branch October 22, 2026 23:01
@OmarShehe OmarShehe mentioned this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant