@@ -384,26 +384,26 @@ export const CrudMixin = (superClass) =>
384
384
this . $ . dialog . $ . overlay . addEventListener ( 'vaadin-overlay-outside-click' , this . __cancel ) ;
385
385
this . $ . dialog . $ . overlay . addEventListener ( 'vaadin-overlay-escape-press' , this . __cancel ) ;
386
386
387
+ this . _gridController = new GridSlotController ( this ) ;
388
+ this . addController ( this . _gridController ) ;
389
+
390
+ // Init button controllers in `ready()` (not constructor) so that Flow can set `_noDefaultButtons`
391
+ this . _newButtonController = new ButtonSlotController ( this , 'new' , 'primary' , this . _noDefaultButtons ) ;
392
+ this . addController ( this . _newButtonController ) ;
393
+
387
394
this . _headerController = new SlotController ( this , 'header' , 'h3' , {
388
395
initializer : ( node ) => {
389
396
this . _defaultHeader = node ;
390
397
} ,
391
398
} ) ;
392
399
this . addController ( this . _headerController ) ;
393
400
394
- this . _gridController = new GridSlotController ( this ) ;
395
- this . addController ( this . _gridController ) ;
396
-
397
401
this . addController ( new FormSlotController ( this ) ) ;
398
402
399
- // Init controllers in `ready()` (not constructor) so that Flow can set `_noDefaultButtons`
400
- this . _newButtonController = new ButtonSlotController ( this , 'new' , 'primary' , this . _noDefaultButtons ) ;
401
403
this . _saveButtonController = new ButtonSlotController ( this , 'save' , 'primary' , this . _noDefaultButtons ) ;
402
404
this . _cancelButtonController = new ButtonSlotController ( this , 'cancel' , 'tertiary' , this . _noDefaultButtons ) ;
403
405
this . _deleteButtonController = new ButtonSlotController ( this , 'delete' , 'tertiary error' , this . _noDefaultButtons ) ;
404
406
405
- this . addController ( this . _newButtonController ) ;
406
-
407
407
// NOTE: order in which buttons are added should match the order of slots in template
408
408
this . addController ( this . _saveButtonController ) ;
409
409
this . addController ( this . _cancelButtonController ) ;
@@ -484,6 +484,9 @@ export const CrudMixin = (superClass) =>
484
484
} else {
485
485
this . $ . editor . removeAttribute ( 'tabindex' ) ;
486
486
}
487
+ } else if ( oldOpened ) {
488
+ // Teleport form and buttons back to light DOM when closing overlay
489
+ this . __moveChildNodes ( this ) ;
487
490
}
488
491
489
492
this . __toggleToolbar ( ) ;
@@ -522,7 +525,10 @@ export const CrudMixin = (superClass) =>
522
525
// Teleport header node, form, and the buttons to corresponding slots.
523
526
// NOTE: order in which buttons are moved matches the order of slots.
524
527
[ ...nodes , ...buttons ] . forEach ( ( node ) => {
525
- target . appendChild ( node ) ;
528
+ // Do not move nodes if the editor position has not changed
529
+ if ( node . parentNode !== target ) {
530
+ target . appendChild ( node ) ;
531
+ }
526
532
} ) ;
527
533
528
534
// Wait to set label until slotted element has been moved.
0 commit comments