diff --git a/lib/atomic_web/components/image_uploader.ex b/lib/atomic_web/components/image_uploader.ex index 7ff53319..839b3760 100644 --- a/lib/atomic_web/components/image_uploader.ex +++ b/lib/atomic_web/components/image_uploader.ex @@ -6,6 +6,7 @@ defmodule AtomicWeb.Components.ImageUploader do @target - the target to send the event to @width - the width of the uploader area @height - the height of the uploader area + @id - a unique identifier for this uploader instance The component events the parent component should define are: cancel-image - cancels the upload of an image. This event should be defined in the component that you passed in the @target attribute. @@ -13,15 +14,17 @@ defmodule AtomicWeb.Components.ImageUploader do use AtomicWeb, :live_component def render(assigns) do + unique_ref = assigns.id <> "_upload" # Generate a unique reference using the passed id + ~H"""
<.live_file_input upload={@uploads.image} class="hidden" />
+ } phx-drop-target={unique_ref}>

or drag and drop

@@ -48,9 +51,9 @@ defmodule AtomicWeb.Components.ImageUploader do
<%= if String.length(entry.client_name) < 30 do %> - <% entry.client_name %> + <%= entry.client_name %> <% else %> - <% String.slice(entry.client_name, 0..30) <> "... " %> + <%= String.slice(entry.client_name, 0..30) <> "... " %> <% end %>