Skip to content

Commit ef11892

Browse files
authored
Fix outdated flash component example in docs (#6631)
The example used `show("#flash")` which does not match the default generated id (`flash-#{kind}`), and was missing the `hidden` attribute needed for `phx-mounted` to work correctly. Updated to follow the same pattern used by the server-error and client-error flashes in the generated layouts. Closes #6624
1 parent 8fb466e commit ef11892

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

installer/templates/phx_web/components/core_components.ex.eex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ defmodule <%= @web_namespace %>.CoreComponents do
3737
## Examples
3838

3939
<.flash kind={:info} flash={@flash} />
40-
<.flash kind={:info} phx-mounted={show("#flash")}>Welcome Back!</.flash>
40+
<.flash
41+
id="welcome-back"
42+
kind={:info}
43+
phx-mounted={show("#welcome-back") |> JS.remove_attribute("hidden")}
44+
hidden
45+
>
46+
Welcome Back!
47+
</.flash>
4148
"""
4249
attr :id, :string, doc: "the optional id of flash container"
4350
attr :flash, :map, default: %{}, doc: "the map of flash messages to display"

0 commit comments

Comments
 (0)