diff --git a/lib/postland_web/components/core_components.ex b/lib/postland_web/components/core_components.ex index bdea082..122ed25 100644 --- a/lib/postland_web/components/core_components.ex +++ b/lib/postland_web/components/core_components.ex @@ -145,14 +145,10 @@ defmodule PostlandWeb.CoreComponents do >
- <.input - type="textarea" - placeholder="alt text" - name={@attachment["url"]} - phx-change="change_alt_text" - phx-value-url={@attachment["url"]} - value={@attachment["name"]} - /> + <.form phx-change="change_alt_text"> + <.input type="textarea" name="alt" placeholder="alt text" value={@attachment["name"]} /> + <.input type="hidden" name="url" value={@attachment["url"]} /> +
<.modal id={"modal-#{Base.url_encode64(attachment["url"], padding: false)}"}> -
- +
+ {attachment["name"]}
diff --git a/lib/postland_web/live/timeline_live.ex b/lib/postland_web/live/timeline_live.ex index 41243cd..670cdc0 100644 --- a/lib/postland_web/live/timeline_live.ex +++ b/lib/postland_web/live/timeline_live.ex @@ -6,10 +6,12 @@ defmodule PostlandWeb.TimelineLive do def render(assigns) do ~H""" - <.post_form post_content={@post} attachments={@attachments} upload={@uploads.files} /> -
-
- <.post_card post={post} post_dom_id={id} /> +
+ <.post_form post_content={@post} attachments={@attachments} upload={@uploads.files} /> +
+
+ <.post_card post={post} post_dom_id={id} /> +
""" @@ -77,7 +79,17 @@ defmodule PostlandWeb.TimelineLive do end def handle_event("change_alt_text", %{"alt" => value, "url" => url}, socket) do - {:noreply, socket} + attachments = + socket.assigns.attachments + |> Enum.map(fn + %{"url" => ^url} = attachment -> + Map.put(attachment, "name", value) + + other -> + other + end) + + {:noreply, assign(socket, attachments: attachments)} end def handle_progress(:files, entry, socket) do