@@ -17,6 +17,16 @@ defmodule Backpex.HTML.Resource do
1717
1818 embed_templates ( "resource/*" )
1919
20+ @ doc """
21+ Returns the list of assigns that `Phoenix.LiveView` reserves and that must be dropped
22+ before spreading parent assigns into a child `Phoenix.LiveComponent`.
23+
24+ `Phoenix.Component.assign/3` rejects these keys with an `ArgumentError`. Centralizing
25+ the list here ensures every spread site forwards the same safe subset of the parent's
26+ assigns.
27+ """
28+ def lv_reserved_assigns , do: [ :flash , :uploads , :streams , :socket , :myself ]
29+
2030 @ doc """
2131 Renders a resource table.
2232 """
@@ -112,7 +122,7 @@ defmodule Backpex.HTML.Resource do
112122 id = { "resource_#{ @ name } _#{ @ primary_key } " }
113123 module = { @ field_options . module }
114124 type = { @ type }
115- { Map . drop ( assigns , [ :socket , :flash , :myself , :uploads ] ) }
125+ { Map . drop ( assigns , lv_reserved_assigns ( ) ) }
116126 />
117127 """
118128 end
@@ -148,7 +158,7 @@ defmodule Backpex.HTML.Resource do
148158 id = { @ id }
149159 module = { @ field_options . module }
150160 type = { @ type }
151- { Map . drop ( assigns , [ :socket , :flash , :myself , :uploads ] ) }
161+ { Map . drop ( assigns , lv_reserved_assigns ( ) ) }
152162 />
153163 """
154164 end
@@ -183,7 +193,7 @@ defmodule Backpex.HTML.Resource do
183193 module = { @ field_options . module }
184194 lv_uploads = { assigns [ :uploads ] }
185195 type = { @ type }
186- { Map . drop ( assigns , [ :socket , :flash , :myself , :uploads ] ) }
196+ { Map . drop ( assigns , lv_reserved_assigns ( ) ) }
187197 />
188198 """
189199 end
0 commit comments