From b557fe3eea6f241acb5eae776adde2dc57acda11 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sat, 9 May 2026 20:11:51 +0100 Subject: [PATCH] Fix record picker search results clearing on add The update/2 callback unconditionally reset the query and results to empty on every parent re-render. Changed to assign_new/3 so search state persists when the parent updates the record set after adding a record. --- lib/music_library_web/live/record_set_live/record_picker.ex | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/music_library_web/live/record_set_live/record_picker.ex b/lib/music_library_web/live/record_set_live/record_picker.ex index a9c4ebd3..96c8bbeb 100644 --- a/lib/music_library_web/live/record_set_live/record_picker.ex +++ b/lib/music_library_web/live/record_set_live/record_picker.ex @@ -140,9 +140,9 @@ defmodule MusicLibraryWeb.RecordSetLive.RecordPicker do {:ok, socket |> assign(assigns) - |> assign(:query, "") - |> assign(:collected_results, []) - |> assign(:wishlisted_results, []) + |> assign_new(:query, fn -> "" end) + |> assign_new(:collected_results, fn -> [] end) + |> assign_new(:wishlisted_results, fn -> [] end) |> assign(:existing_record_ids, existing_record_ids)} end