Skip to content

NumberForm foundation 2: FlipButton and CurrencyButton primitives #98170

Closed

Description

@mountiny

Sub-issue of #97970.
Migration plan: jmgraa comment.

The currency button is implemented four times inside NumberWithSymbolForm and the flip button three times. This issue collapses each into one primitive with a minimal prop set and its own tests.

Scope

  • Step: 2 of the migration plan
  • Scope: 2 new primitives under src/components/NumberForm/primitives/

Target API

<NumberForm value={amount} onInputChange={handleAmount}>
    <NumberForm.Input symbol="$" position="prefix" />
    <NumberForm.FlipButton />
    <NumberForm.CurrencyButton currency="USD" onPress={handleCurrency} />
</NumberForm>

Duplication being collapsed

Line numbers are against src/components/NumberWithSymbolForm.tsx on main.

Currency button, 4 copies:

Line Path Gate
515 displayAsTextInput right hand side shouldShowCurrencyButton && currencyOrUnitButtonText, calls onTrailingDropdownPress
647 landscape isSymbolPressable
727 portrait isSymbolPressable && !!currency && !canUseTouchScreen
753 portrait isSymbolPressable && canUseTouchScreen

The last three are near identical — same icons.CoinsButton, same styles.minWidth18, same onSymbolButtonPress, same text={currency} — and differ only in touch gating.

Flip button, 3 copies:

Line Path Gate Negate mechanism
502 displayAsTextInput shouldShowFlipButton && allowNegativeInput && canUseTouchScreen internal handleFlipPress (line 470)
659 landscape allowFlippingAmount caller supplied toggleNegative
765 portrait allowFlippingAmount && canUseTouchScreen caller supplied toggleNegative

Three things to fix while collapsing

  1. Pick one negate mechanism. Two coexist today: the internal handleFlipPress and the caller supplied toggleNegative. NumberForm.FlipButton should own negation through the root's negativeMode, and callers should not have to hand in a toggle.
  2. Drop the dead parallel API. currencyButtonLabel / onCurrencyButtonPress and currency / onSymbolButtonPress are two APIs for the same trailing button, resolved at lines 242 and 243 with ??. NumberForm.CurrencyButton takes one pair.
  3. Make touch detection reactive. const canUseTouchScreen = canUseTouchScreenUtil() at line 141 is evaluated at import time, so the touch and non touch branches never re-evaluate. Read it inside the component instead.

Also collapse the FormHelpMessage duplication (lines 672 and 739, differing only in style) into whatever the primitives share.

Out of scope

  • The number pad and layout composition — #98171
  • Any call site change

Acceptance criteria

  • One NumberForm.CurrencyButton replaces all four copies
  • One NumberForm.FlipButton replaces all three copies
  • Negation is owned by the primitive, driven by the root's negativeMode
  • Only one currency button API pair survives
  • Touch detection is reactive, not evaluated at import time
  • Dedicated tests for both primitives, covering the touch and non touch gates
  • NumberWithSymbolForm behaviour is unchanged, and the tests from #98168 still pass
  • Verify that no errors appear in the JS console

Dependencies

Issue OwnerCurrent Issue Owner: @bernhardoj

Activity

  1. added
    Weekly
    Skip Payment
    on Aug 10, 2026
  2. added and removed
    Weekly
    on Sep 2, 2026
  3. melvin-bot commented on Sep 2, 2026

    @melvin-bot

    This issue has not been updated in over 15 days. @mountiny, @bernhardoj, @jmgraa eroding to Monthly issue.

    P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

  4. added
    Reviewing
    Weekly
    and removed on Sep 14, 2026
  5. added
    Daily
    and removed
    Reviewing
    Weekly
    on Sep 23, 2026
  6. melvin-bot commented on Sep 23, 2026

    @melvin-bot

    @bernhardoj

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.4.91-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

  7. jmgraa commented on Nov 13, 2026

    @jmgraa
    Contributor

    Implementation Note & Architecture Delta

    The button primitives were implemented in src/components/AmountActionButtons/ (AmountCurrencyPickerButton and AmountSignFlipButton) and exposed through their respective composite parents:

    • KeypadAmountEditor.CurrencyPickerButton / KeypadAmountEditor.SignFlipButton (rendered in the actions slot)
    • AmountFormField.CurrencyPickerButton / AmountFormField.SignFlipButton (composed as children inside AmountFormField.Input)

    Note

    Suggested Title Update:
    NumberWithSymbolForm foundation 2: Action button primitives (CurrencyPicker & SignFlip)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

DailySkip PaymentTask

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions