Keep the extra repayment amount and Apply on one row

Merged
JA
2mo ago
+68-2

Closes jaysbeekay/sure#469

Problem

On a loan's Extra repayments tab, the amount field filled the whole row and Apply wrapped beneath it. The input also drew its own dark border inside the field's card, a box inside a box. .form-field applies w-full (app/assets/tailwind/sure-design-system/components.css:39), so inside the flex flex-wrap row it took every column. The input had no form-field__input and the label no form-field__label.

Change

app/views/loans/tabs/_extra_repayments.html.erb only:

  • The field is form-field w-48. w-48 is a scale token, and the utilities layer wins over the component's w-full, so the field shares its row with Apply (and Clear, once an amount is applied).
  • The label carries form-field__label and the input form-field__input, so the card is the field's only box, as on the loan form.
  • Unchanged: the form's URL, method and params (extra_payment[amount]), the auto-submit target, min/step, and the Clear link. .form-field itself is not edited, so no other form changes.

Blast radius. The partial is rendered only by app/views/accounts/show/_extra_repayments_frame.html.erb. AccountsController#show and the auto-submit-form controller see the same request as before.

Screenshots

Default desktop viewport (1400px). Taken with the test suite's Selenium browser on this branch and on main.

LightDark
Before (main)before, lightbefore, dark
Afterafter, lightafter, dark

Tests

Each test was written first and seen to fail on main:

  • AccountsControllerTest "the extra repayment amount is a design-system field input": inside .form-field, label.form-field__label[for='extra_payment_amount'] and input.form-field__input[name='extra_payment[amount]']. On main: Expected exactly 1 element matching "label.form-field__label..." found 0.
  • LoanExtraRepaymentsTest (new system test) "the extra repayment amount and Apply share one row": at the default 1400px viewport, Apply's top is above the field's bottom and Apply sits to the field's right. On main, Apply's top was 741 against the field's bottom 733, so it had wrapped.
  • Negative: the existing extra-repayment tests that submit an amount and read extra-payoff-date / extra-months-sooner still pass, so the form submits the same params.

Mutations, each on the committed fix and restored with git checkout --:

MutationResult
Drop w-48system test fails (Apply's top 719 vs field bottom 711)
Drop form-field__inputcontroller test fails
Drop form-field__labelcontroller test fails

Validation

  • bin/rails test on a6daf0b3b: 12,403 runs, 53,507 assertions, 0 failures, 0 errors, 35 skips.
  • System tests loan_extra_repayments_test.rb and loan_payoff_chart_test.rb: 4 runs, 0 failures (remote Chromium).
  • bin/rubocop on the changed tests: no offenses. erb_lint on the partial: no errors. bin/brakeman --no-pager -q: 0 warnings.
  • Upstream AGENTS.md: DS field classes, a scale token rather than an arbitrary width, no raw palette classes, no new styles in the design-system files, and t() strings unchanged.