Skip to content

Surface registration errors with a scroll-to error band#1760

Open
maebeale wants to merge 1 commit into
mainfrom
maebeale/form-submission-error-flash
Open

Surface registration errors with a scroll-to error band#1760
maebeale wants to merge 1 commit into
mainfrom
maebeale/form-submission-error-flash

Conversation

@maebeale

@maebeale maebeale commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Closes [link an issue or remove this line]

What is the goal of this PR and why is this important?

  • A failed public event registration re-rendered the long form showing only inline per-field errors — easy to miss, and the page didn't move, so it wasn't obvious anything had gone wrong.

How did you approach the change?

  • On a failed validation, render a red summary band at the top of the form listing each offending field and its message (covers both registration and scholarship fields).
  • A small form-errors Stimulus 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.
  • Admin-side registration is intentionally untouched (it already shows a top error summary via shared/_errors).

UI Testing Checklist

  • Submit the public registration form with a required field missing → red band appears at top, page scrolls to it, each bad field is listed.
  • Submit a valid form → no band, normal success flow.

Anything else to add?

// 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() {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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 maebeale marked this pull request as ready for review June 18, 2026 23:33
@jmilljr24

Copy link
Copy Markdown
Collaborator

@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 jmilljr24 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) ])

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 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.

@maebeale

maebeale commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator Author

@jmilljr24 what do you think about the one-time "You're registered" text? I could move that to another PR.

@maebeale

Copy link
Copy Markdown
Collaborator Author

@jmilljr24 will your error also capture errors on scholarship fields?

@maebeale

Copy link
Copy Markdown
Collaborator Author

@jmilljr24 also there's an extra validation re value is too long that wasn't being handled gracefully. i'd like to deploy that.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to stick with standard rails flash and avoid extra js.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen this but seems worthwhile.

</div>
<% end %>

<% if @field_errors&.any? %>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how this is different from the flash[:alert] on line 88

Image

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each section was already displaying the correct error for each field.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 %>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we can get away with sticking with a flash message and not adding any extra variables.

@jmilljr24

Copy link
Copy Markdown
Collaborator

@jmilljr24 what do you think about the one-time "You're registered" text? I could move that to another PR.

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.

@maebeale maebeale force-pushed the maebeale/form-submission-error-flash branch from 3eef4a5 to aeae193 Compare June 19, 2026 03:51
@maebeale maebeale changed the title Signal registration submit outcome (error band + auto-scroll, success banner) HOLD: Signal registration submit outcome (error band + auto-scroll, success banner) Jun 19, 2026
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>
@maebeale maebeale force-pushed the maebeale/form-submission-error-flash branch from aeae193 to 7e37ea1 Compare June 19, 2026 04:00
@maebeale maebeale changed the title HOLD: Signal registration submit outcome (error band + auto-scroll, success banner) Surface registration errors with a scroll-to error band Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants