ELI7VH
Strange bug with line breaks in .html.leex
Hi friends, running into a weird bug when using a new live view project
in my live.html.leex file, if i format the code like so:
<main role="main" class="container">
<p
class="alert alert-info"
role="alert"
phx-click="lv:clear-flash"
phx-value-key="info"
>
<%= live_flash(@flash, :info) %>
</p>
<%= @inner_content %>
</main>
My alert box will render unconditionally (the blue box)
if I change the code back to the default formatting that came with the new project:
<main role="main" class="container">
<p class="alert alert-info" role="alert"
phx-click="lv:clear-flash"
phx-value-key="info"><%= live_flash(@flash, :info) %></p>
<%= @inner_content %>
</main>
the alert box disappears! ![]()
![]()
![]()
![]()
very confused. If this is a bug, can somebody lead me to where I might report it?
I have tried this with both LF and CRLF set
the most minimal reproduction of this bug is putting a new line between the p tag and the <%= tag like so:
<main role="main" class="container">
<p class="alert alert-info" role="alert"
phx-click="lv:clear-flash"
phx-value-key="info">
<%= live_flash(@flash, :info) %></p>
<%= @inner_content %>
</main>
Marked As Solved
ELI7VH
with the help of somebody on slack, the mystery has been solved!
In the boilerplate CSS, the box is hidden if there is no content. A line break is considered content in DOM land.
if you run into this, just switch to conditionally rendering the alert boxes, or use a conditional css class (if you want fancy animations and such
)
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










