Skip to content

fix(tipping): cap the tip preset buttons at three digits - #1381

Merged
bmc08gt merged 2 commits into
code/cashfrom
fix/tip-preset-digit-cap
Aug 31, 2026
Merged

fix(tipping): cap the tip preset buttons at three digits#1381
bmc08gt merged 2 commits into
code/cashfrom
fix/tip-preset-digit-cap

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

The preset buttons split the tip modal's width three ways and write the amount out in full. In USD the tiers are $5 / $10 / $20 and fit; localized to a low-value currency they do not. The same tiers are 7,500 / 15,000 / 30,000 pesos, and a custom amount can be larger still.

Fiat.abbreviated() caps the visible amount at three digits. Under 1,000 it formats exactly as before; above that it scales to K/M/B/T, keeping only the decimals the cap leaves room for and dropping trailing zeros. It rounds to significant digits before choosing the scale, so 999,999 prints as $1M rather than $1,000K.

written out on the button
ARS 7,500 / 25,500 / 123,456 7.5K / 25.5K / 123K
VND 126,000 / 1,315,000 126K / 1.32M
IDR 332,000 332K
JPY 750 / 3,000 750 / 3K
USD $5 / $12.50 unchanged

The button's content description keeps the full amount, so the abbreviation is visual only and TalkBack still reads "332,000".

The helper formats through Fiat, so the currency symbol, grouping, and per-currency fraction digits are preserved. FiatTest covers the scale boundaries, the decimal cap, the carry into the next scale, and the currencies above.

Discovery uses the same rule

The second commit moves discovery's market caps, holder counts and deltas onto it. They previously went through Number.abbreviated(), which had its own rule — two decimals at every scale, so a delta could run to five digits (+$999.99K) — and two defects that the shared implementation does not have:

  • The scale came from the unrounded value, so a delta of 999,999 printed as $1000K.
  • The scale thresholds were >= comparisons on the signed value, so no negative ever matched one. A holder delta of -12,345 rendered in full, even though the call site's comment expects the sign to carry through an abbreviation.

Both helpers now share the rounding and scale selection; only the final formatting differs, because Fiat needs the currency symbol and Number does not. Discovery reads 1.23K / 693K / -12.3K.

One behaviour change below a thousand: values are now rounded instead of truncated, so a fractional market cap delta of 42.7 shows as 43. Holder counts are whole, so this only reaches market cap figures.

Unchanged by this PR, but worth knowing: ARS, IDR and COP resolve no single-character symbol through CurrencyCode.singleCharacterCurrencySymbol, so those buttons show bare digits. Full formatting drops the symbol too, but it reads as more of a gap now that the number is short.

The preset buttons split the modal's width three ways, and the amount inside
each is written out in full. In USD the tiers are $5 / $10 / $20 and fit, but
the same tiers localized to a low-value currency do not: 7,500 / 15,000 /
30,000 pesos, Rp332,000, or a custom amount larger still.

`Fiat.abbreviated()` caps the visible amount at three digits. Anything under
1,000 formats as it did before, and larger amounts scale to K/M/B/T with only
the decimals the cap leaves room for, trailing zeros dropped: 7.5K, 25.5K,
123K, 1.25M. It rounds to significant digits before choosing the scale, so
999,999 prints as $1M rather than $1,000K.

The button's content description still carries the full amount, so the
abbreviation is visual only and TalkBack reads "332,000".

It lives beside the existing `Number.abbreviated()` in core and follows its
K/M/B/T casing, but formats through `Fiat` so the currency symbol, grouping,
and per-currency fraction digits stay intact.
@bmc08gt bmc08gt self-assigned this Aug 31, 2026
@github-actions github-actions Bot added type: fix Bug fix area: payments Payments, transfers, intents, billing labels Aug 31, 2026
@bmc08gt

bmc08gt commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

Deliberately not identical to the iOS side, code-ios-app#704, which does the same job for the Send a Tip chips. That one keeps a decimal only while the scaled figure is a single digit; this keeps three significant digits. The same preset therefore reads $1.23K / $25.5K here and $1.2K / $26K there.

Two smaller differences, same decision: this abbreviates the custom "…" slot as well, where iOS leaves it formatting exactly, and Number.abbreviated() (market cap in Discovery) stays its own rule, where iOS folded CompactCurrencyFormatStyle onto the new one.

Discovery formatted market caps, holder counts and their deltas with its own
rule: two decimals at every scale, so a delta could take five digits
("+$999.99K"). It also picked the scale from the unrounded value, printing
999,999 as "1000K", and compared signed values against the scale thresholds,
so a negative holder delta never abbreviated at all — -12,345 rendered in
full despite the call site expecting "-12.3K".

Move the scale selection onto the three-digit rule the tip presets use and
share it between the two: round to three significant digits first, pick the
scale from the rounded value, then keep only the decimals the cap leaves room
for. Discovery now reads 1.23K / 693K / -12.3K.

Values below a thousand are now rounded rather than truncated, so a fractional
market cap delta of 42.7 shows as 43 instead of 42.
@bmc08gt
bmc08gt merged commit a2a0a64 into code/cash Aug 31, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: payments Payments, transfers, intents, billing type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant