From cd2bfa8eb521c824ae4f8ee36f6312102dfc0c05 Mon Sep 17 00:00:00 2001 From: Guillem Arias Date: Thu, 14 May 2026 21:59:11 +0200 Subject: [PATCH] fix(goals/pledge): redirect non-turbo-frame GET to goal show MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UX audit: `app/views/goal_pledges/new.html.erb` unconditionally renders the form in a DS::Dialog wrapper — when the user lands on `/goals/:id/pledges/new` directly (F5, bookmark, stale deep-link), the dialog renders as a freestanding modal over an otherwise-empty page. Compare to `goals/new.html.erb` which has a `turbo_frame_request?` branch with a full-page fallback. Pledges aren't usefully standalone — the modal only makes sense in goal context. Redirect non-frame GETs back to the goal show page instead of rendering the broken-looking standalone dialog. If we want a deep-linkable "open the pledge modal" experience later, that lands as a `?open=pledge` query on the show page that auto-fires the modal — out of scope here. --- app/controllers/goal_pledges_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/goal_pledges_controller.rb b/app/controllers/goal_pledges_controller.rb index e33e00b1b..e7e0bf398 100644 --- a/app/controllers/goal_pledges_controller.rb +++ b/app/controllers/goal_pledges_controller.rb @@ -4,6 +4,14 @@ class GoalPledgesController < ApplicationController rescue_from ActiveRecord::RecordNotFound, with: :record_not_found def new + # The form is dialog-only. A direct GET (F5, bookmark, deep-link + # gone stale) lands the user back on the goal show page with the + # modal auto-opened via the catch-up CTA params, rather than + # rendering a freestanding DS::Dialog over an empty page. + unless turbo_frame_request? + redirect_to goal_path(@goal) and return + end + account = preselected_account @pledge = @goal.goal_pledges.new( currency: @goal.currency,