Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fire turbo:frame-load event during form submission #425

Merged
merged 1 commit into from
Nov 9, 2021

Conversation

seanpdoyle
Copy link
Contributor

@seanpdoyle seanpdoyle commented Oct 18, 2021

Prior to this change, whenever a <form> submission drove a
<turbo-frame> element, turbo:frame-render events would fire but
turbo:frame-load events would not. The implementation to handle
navigations initiated by [src]-based attribute changes diverges from
the code paths that handle form submissions and 4xx response
rendering.

Regardless of any plans to re-structure those code paths, it's important to ensure that
turbo:frame-load events fire regardless of how the <turbo-frame> was
navigated.

Prior to this change, whenever a `<form>` submission drove a
`<turbo-frame>` element, `turbo:frame-render` events would fire but
`turbo:frame-load` events would not. The implementation to handle
navigations initiated by `[src]`-based attribute changes diverges from
the code paths that handle form submissions and `4xx` response
rendering.

Prior to re-structuring those code paths, it's important to ensure that
`turbo:frame-load` events fire regardless of how the `<turbo-frame>` was
navigated.
@seanpdoyle seanpdoyle force-pushed the frame-form-fires-load-event branch from 1f03db5 to fe01bac Compare October 18, 2021 14:24
@dhh dhh merged commit adc55c6 into hotwired:main Nov 9, 2021
@seanpdoyle seanpdoyle deleted the frame-form-fires-load-event branch November 9, 2021 13:36
@daniel-rikowski
Copy link

daniel-rikowski commented Sep 14, 2022

As far as I understand this is the feature people were asking for in #85, #325 and #520, but just for Turbo Frames and not the whole page.

If I may ask, what was the reasoning for this change? I.e. why is a turbo:frame-load event triggered for 4xx form responses in a frame, but no turbo:load for 4xx form responses on the page?

Given this statement:

it's important to ensure that turbo:frame-load events fire regardless of how the <turbo-frame> was navigated.

I fully agree, and I would also argue:

it's important to ensure that turbo:load events fire regardless of how the <body> was navigated.

I might be missing something here, sorry if this is a dumb question...

Thank you for your great work, BTW!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants