@@ -1860,8 +1860,14 @@ window.L.Control.JSDialogBuilder = window.L.Control.extend({
18601860 if ( data . command )
18611861 window . L . DomUtil . addClass ( div , data . command . replace ( ':' , '' ) . replace ( '.' , '' ) ) ;
18621862
1863- if ( isRealUnoCommand )
1863+ if ( isRealUnoCommand ) {
1864+ // there is a problem with JSON crafted manually on the JS side
1865+ // we do not have warranty the id we passed is the one used in the DOM
1866+ // updates might then fail to find such item
1867+ // we need to remember the original ID
1868+ div . setAttribute ( 'modelId' , id ) ;
18641869 id = JSDialog . MakeIdUnique ( id ) ;
1870+ }
18651871
18661872 div . id = id ;
18671873 data . id = id ; // change in input data for postprocess
@@ -2392,15 +2398,24 @@ window.L.Control.JSDialogBuilder = window.L.Control.extend({
23922398 builder . _explorableMenu ( parentContainer , title , data . children , builder , content , data . id ) ;
23932399 } ,
23942400
2401+ _getItemById : function ( container , id ) {
2402+ const plainId = this . _removeMenuId ( id ) ;
2403+ // prefer the modelId first which is unique within single component, DOM id might be changed due to conflict
2404+ let control = container . querySelector ( '[modelId=\'' + plainId + '\']' ) ;
2405+ if ( ! control )
2406+ control = container . querySelector ( '[id=\'' + plainId + '\']' ) ;
2407+ return control ;
2408+ } ,
2409+
23952410 // executes actions like changing the selection without rebuilding the widget
23962411 executeAction : function ( container , data ) {
23972412 app . layoutingService . appendLayoutingTask ( ( ) => { this . executeActionImpl ( container , data ) ; } ) ;
23982413 } ,
23992414
24002415 executeActionImpl : function ( container , data ) {
2401- var control = container . querySelector ( '[id=\'' + this . _removeMenuId ( data . control_id ) + '\']' ) ;
2416+ let control = this . _getItemById ( container , this . _removeMenuId ( data . control_id ) ) ;
24022417 if ( ! control && data . control )
2403- control = container . querySelector ( '[id=\'' + this . _removeMenuId ( data . control . id ) + '\']' ) ;
2418+ control = this . _getItemById ( container , this . _removeMenuId ( data . control . id ) ) ;
24042419 if ( ! control ) {
24052420 window . app . console . warn ( 'executeAction: not found control with id: "' + data . control_id + '"' ) ;
24062421 return ;
@@ -2542,8 +2557,8 @@ window.L.Control.JSDialogBuilder = window.L.Control.extend({
25422557 } ,
25432558
25442559 _updateWidgetImpl : function ( container , data , buildFunc ) {
2545- var elementId = this . _removeMenuId ( data . id ) ;
2546- var control = container . querySelector ( '[id=\'' + elementId + '\']' ) ;
2560+ const elementId = this . _removeMenuId ( data . id ) ;
2561+ const control = this . _getItemById ( container , elementId ) ;
25472562 if ( ! control ) {
25482563 window . app . console . warn ( 'jsdialogupdate: not found control with id: "' + elementId + '"' ) ;
25492564 return ;
0 commit comments