From 4fca772b00a6f19e07af95944670b2d8a9d309ec Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sun, 7 Sep 2025 14:40:19 +0300 Subject: [PATCH] Reload note after saving --- lib/music_library_web/components/notes_component.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/music_library_web/components/notes_component.ex b/lib/music_library_web/components/notes_component.ex index 17bbf2f5..a96896b3 100644 --- a/lib/music_library_web/components/notes_component.ex +++ b/lib/music_library_web/components/notes_component.ex @@ -120,9 +120,14 @@ defmodule MusicLibraryWeb.NotesComponent do defp create_note(note_params, socket) do case Notes.create_note(socket.assigns.note, note_params) do - {:ok, _record} -> + {:ok, note} -> + changeset = + Note.changeset(note, %{}) + {:noreply, socket + |> assign(:note, note) + |> assign(:form, to_form(changeset)) |> put_toast(:info, gettext("Note created successfully"))} {:error, %Ecto.Changeset{} = changeset} ->