Keep the money field's currency handler next to the transaction form's action
Fixes #3915
Before: on the new transaction form, switching the currency left the amount field's symbol, step and decimal precision on the previous currency (e.g. still $ with 2 decimals after picking JPY or BTC).
After: switching the currency refreshes the symbol, step and precision like every other money field, and the form's own currency check (transaction-form#onCurrencyChange) still runs.
The transaction form passes currency_data with a symbol action: key, while shared/_money_field.html.erb removed the caller's action with a string key (delete("action")). Both keys were rendered, producing two data-action attributes; the browser keeps the first, so money-field#handleCurrencyChange was never wired. Spotted by @jjmata while re-testing #3502.
How: stringify the caller's currency_data keys before merging, so the existing action is found and both handlers are chained (change->money-field#handleCurrencyChange change->transaction-form#onCurrencyChange). transactions/_form.html.erb is the only caller that passes currency_data, so no other form changes.
Validation:
- New controller test asserts the new transaction form's currency select carries both actions; it fails on
mainand passes with the fix. - Full Rails suite locally: 10,430 runs, 0 failures; 2 errors unrelated to this change (a local-only Postgres role issue in
RecurringTransaction::PipelineTest, andReportsControllerTestcolliding with anexchange_ratesfixture datedDate.currenton the first day of the month). test/system/transactions_form_exchange_rate_test.rbgreen, rubocop, erb_lint and brakeman clean.
Note: #3502 also edits shared/_money_field.html.erb (different lines); whichever merges second needs a trivial rebase/merge.
š¤ Generated with Claude Code
Summary by CodeRabbit
- Bug Fixes
- Currency selectors now preserve caller-provided actions while including the handlers needed to update currency fields and transaction forms.