Mark forms created for links with data-turbo-method as hidden #404
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 have an example of some styles breaking when a form is injected into the markup.
CleanShot.2021-09-22.at.16.29.05.mp4
You can see the actions move to the right after clicking the "Undo" link. This is because the actions are spaced out using TailwindCSS's spacing helpers, and the link has a
data-turbo-method
attribute which causes Turbo to create a form and insert it in the DOM before the link. So where there was previously:I now have:
One possible solution would be to use the
hidden
global attribute to indicate that the form is not meant for display. This would allow the ability to handle the styling by targeting theform[hidden]
selector. Conveniently, the TailwindCSS spacing helpers already ignore elements marked ashidden
when applying spacing. Here is the same scenario as above, same DOM and CSS, but with the form'shidden
attribute set.CleanShot.2021-09-22.at.16.37.15.mp4
Thanks for your time in reviewing this!