From 8a414e47773020710b0868e44ab03a63c9affdde Mon Sep 17 00:00:00 2001 From: Guillem Arias Date: Mon, 11 May 2026 20:34:11 +0200 Subject: [PATCH] fix(goal_contributions/preview): rename templateNonZero -> templateNonzero so Stimulus matches the data attribute Stimulus converts the JS value name templateNonZero to a kebab-cased attribute by splitting on each capital letter, giving data-...-template-non-zero-value. Rails' dataset helper converts the Ruby key :goal_contribution_preview_template_nonzero_value to data-...-template-nonzero-value (no hyphen between non and zero). Result: the Stimulus controller resolved templateNonzeroValue to "" and the preview pane went blank as soon as the user typed an amount. Renaming the JS value to templateNonzero closes the conversion gap. Verified live via Playwright: at $500 the preview reads "Will bring you to 28% saved ($13,750 of $50,000)."; at $40,000 it flips to "Will reach your $50,000 target." --- .../controllers/goal_contribution_preview_controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/controllers/goal_contribution_preview_controller.js b/app/javascript/controllers/goal_contribution_preview_controller.js index 714c586f0..22299f69a 100644 --- a/app/javascript/controllers/goal_contribution_preview_controller.js +++ b/app/javascript/controllers/goal_contribution_preview_controller.js @@ -11,7 +11,7 @@ export default class extends Controller { targetAmount: Number, currency: String, templateZero: String, - templateNonZero: String, + templateNonzero: String, templateReached: String, }; @@ -37,7 +37,7 @@ export default class extends Controller { .replaceAll("{current}", this.#money(this.currentBalanceValue)) .replaceAll("{target}", this.#money(target)); } else { - text = this.templateNonZeroValue + text = this.templateNonzeroValue .replaceAll("{percent}", percent.toString()) .replaceAll("{newTotal}", this.#money(newTotal)) .replaceAll("{target}", this.#money(target));