Make Liveview's root divs transparent for layout purposes. #6052
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 suspect this PR might be a slightly hard sell, but I will do my best to motivate my reasons for proposing its inclusion.
LiveView generates non-optional wrapper divs. This presents challenges for using LiveViews in certain layouts. For example, if you want your LiveView to be a flex child, then your best course of action is to add
container: {:div, style: "display: contents"}
when rendering the LiveView.display: contents
makes the element invisible for layout purposes, so the child of the wrapper div effectively replaces the wrapper div in the layout.Another option is to make this the global default for your wrapper divs. This can be done in CSS with the following line:
Adding this to an existing project might be tricky, because it can negate the impact of the
:container
option. But adding it at the beginning of a project seems without risk. And it is nice to have this in place from the beginning, because when you need it you will probably pull your hair out for a day before you figure out how to make the layout work that you want.I think including this PR would be a nice developer experience improvement.
(h/t to @LostKobrakai and @tmjoen for helping me find this solution in Slack)