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

Absence of turbo:load event for 4xx html responses #325

Closed
fwilkens opened this issue Jul 26, 2021 · 2 comments
Closed

Absence of turbo:load event for 4xx html responses #325

fwilkens opened this issue Jul 26, 2021 · 2 comments

Comments

@fwilkens
Copy link

fwilkens commented Jul 26, 2021

Hi,

For those of us on the turbolinks -> turbo upgrade path, it was great to see #39 in response to hotwired/turbo-rails#12 -- thanks for that. One thing I've noticed, however, is that when a 422 html response is rendered by Turbo in cases like this, turbo:load is not fired. I just checked in one of our apps with turbolinks, and it looks like Turbolinks would fire turbolinks:load in such a case.

The outcome with Turbo is that the 422 html response is rendered, but javascript functionality that hinges on turbo:load is broken. My expectation was that turbo:load would fire -- is that a reasonable expectation or is there something I'm missing here? One obvious solution is to refactor these cases to use a frame or stream I guess, but my hope after seeing #39 was that I could avoid frame/stream refactors until after the initial swap of turbo in for turbolinks and validating that Drive worked more/less ootb with our apps (following the notes in https://github.com/hotwired/turbo-rails/blob/main/UPGRADING.md).

Here's a repo demonstrating the lack of the turbo:load event in such a case (forked and slightly modified demo chat app) https://github.com/fwilkens/hotwire-rails-demo-chat/tree/demo_422_no_event. To see the issue, submit the New room form without a name, and note that there's no console log for the event listener on turbo:load.

@willnet
Copy link

willnet commented Aug 20, 2021

@fwilkens I know it's inconvenient, but this is an intentional specification.

#85 (comment)

@fwilkens
Copy link
Author

Thanks @willnet -- not sure how missed that issue. I guess I'll close this issue, since 85 was closed with an explanation.

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

No branches or pull requests

2 participants