@@ -104,14 +104,6 @@ export class HuiPictureElementsCardEditor
104104 this . _handleSubElementChanged ( updateEvent ) ;
105105 }
106106
107- private _configWithPreviewCallback (
108- config : PictureElementsCardConfig
109- ) : PictureElementsCardConfig {
110- const configWithCallback = { ...config } ;
111- ( configWithCallback as any ) [ PREVIEW_CLICK_CALLBACK ] = this . _onPreviewClick ;
112- return configWithCallback ;
113- }
114-
115107 private _schema = memoizeOne (
116108 ( localize : LocalizeFunc ) =>
117109 [
@@ -236,6 +228,7 @@ export class HuiPictureElementsCardEditor
236228 return ;
237229 }
238230
231+ // no need to attach the preview click callback here, no element is being edited
239232 fireEvent ( this , "config-changed" , { config : ev . detail . value } ) ;
240233 }
241234
@@ -246,11 +239,10 @@ export class HuiPictureElementsCardEditor
246239 const config = {
247240 ...this . _config ,
248241 elements : ev . detail . elements as LovelaceElementConfig [ ] ,
242+ [ PREVIEW_CLICK_CALLBACK ] : this . _onPreviewClick ,
249243 } as PictureElementsCardConfig ;
250244
251- fireEvent ( this , "config-changed" , {
252- config : this . _configWithPreviewCallback ( config ) ,
253- } ) ;
245+ fireEvent ( this , "config-changed" , { config } ) ;
254246
255247 const newLength = ev . detail . elements ?. length || 0 ;
256248 if ( newLength === oldLength + 1 ) {
@@ -290,7 +282,10 @@ export class HuiPictureElementsCardEditor
290282 } ;
291283
292284 fireEvent ( this , "config-changed" , {
293- config : this . _configWithPreviewCallback ( this . _config ) ,
285+ config : {
286+ ...this . _config ,
287+ [ PREVIEW_CLICK_CALLBACK ] : this . _onPreviewClick ,
288+ } ,
294289 } ) ;
295290 }
296291
0 commit comments