Surface registration errors with a scroll-to error band#1760
Conversation
| // banner into view so the registrant immediately sees what needs fixing. | ||
| // Attached to the banner itself, so it only connects when errors are present. | ||
| export default class extends Controller { | ||
| connect() { |
There was a problem hiding this comment.
🤖 From Claude: Controller is attached to the error banner itself rather than the form, so it only ever connects when errors are present — no guard/target needed, and it scrolls its own element into view.
| flash.now[:alert] = "Payment was cancelled. You are registered for this event but payment may still be due." | ||
| end | ||
|
|
||
| @just_registered = params[:registered].present? || params[:checkout] == "success" |
There was a problem hiding this comment.
🤖 From Claude: Banner fires for a fresh registration (?registered=true) and for a successful Stripe return (checkout=success), but not on plain ticket re-visits.
|
@maebeale I think the standard flash message I added is sufficient in another PR. Rudy was happy with the change. I would want further testing of this changes, no rushing |
jmilljr24
left a comment
There was a problem hiding this comment.
I'd like to wait on this.
| Result.new(success?: true, event_registration: event_registration, form_submission: submission, errors: []) | ||
| end | ||
| rescue ActiveRecord::ValueTooLong => e | ||
| Result.new(success?: false, event_registration: nil, errors: [ too_long_message(e) ]) |
There was a problem hiding this comment.
🤖 From Claude: ValueTooLong is a StatementInvalid, not a RecordInvalid, so it needs its own rescue — otherwise an answer longer than its varchar(255) column 500s mid-registration instead of re-rendering the form.
|
@jmilljr24 what do you think about the one-time "You're registered" text? I could move that to another PR. |
|
@jmilljr24 will your error also capture errors on scholarship fields? |
|
@jmilljr24 also there's an extra validation re value is too long that wasn't being handled gracefully. i'd like to deploy that. |
There was a problem hiding this comment.
I'd like to stick with standard rails flash and avoid extra js.
There was a problem hiding this comment.
On second look, I don't see where this is used.
|
|
||
| Result.new(success?: true, event_registration: event_registration, form_submission: submission, errors: []) | ||
| end | ||
| rescue ActiveRecord::ValueTooLong => e |
There was a problem hiding this comment.
I haven't seen this but seems worthwhile.
| </div> | ||
| <% end %> | ||
|
|
||
| <% if @field_errors&.any? %> |
There was a problem hiding this comment.
Each section was already displaying the correct error for each field.
There was a problem hiding this comment.
bc people miss flash messages. there's too much text at top of form to see the field errors, and people aren't realizing the form didn't submit.
| <% end %> | ||
| </div> | ||
| </div> | ||
| <% if @just_registered %> |
There was a problem hiding this comment.
i think we can get away with sticking with a flash message and not adding any extra variables.
Nothing inherently wrong with it but in some ways is redundant to the flash message (standard flow) with additional conditional code. I don't feel its worth it. |
3eef4a5 to
aeae193
Compare
A failed public registration re-rendered the long form with only inline per-field errors — easy to miss, and the page didn't move, so it wasn't obvious anything was wrong. Add a summary band at the top of the form listing each offending field, and a small form-errors Stimulus controller (attached to the band) that scrolls it into view on connect. This replaces the generic "scroll down for errors" flash. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
aeae193 to
7e37ea1
Compare

Closes [link an issue or remove this line]
What is the goal of this PR and why is this important?
How did you approach the change?
form-errorsStimulus controller, attached to the band itself, scrolls it into view on connect — so it only fires when errors are present. Works on both the Turbo (free-event) and full-page (paid-event) submit paths.shared/_errors).UI Testing Checklist
Anything else to add?
AGENTS.md(was stale at 71 → now 74).