Show Rails error page for a morph reload #56
+58
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that in contrast to the
:replace
reload method,:morph
will not display the Rails error page if an updated page raises an error. It will only print an error to the browser's console.I changed the MorphReloader to morph the complete
<html>
document, to handle the different<head>
s between the Rails error page and the app's layout. This would theoretically also fix that a change to an app's layout would not get picked up by the:morph
method currently.While the tests are green, my PR is broken, because after morphing from error page to a fixed version, I get the following browser error:
An import map is added after module script load was triggered.
and Stimulus controllers run twice.I decided to open up the PR anyways, to start a discussion about a potential implementation or if someone has an idea how to approach the morph error page. I'll probably take another stab tomorrow and try to use Turbo for the Morph Reloader but I ran out of ideas for today.