@@ -31,30 +31,31 @@ export class Dialog {
3131 private input : HTMLInputElement | undefined ;
3232 private errors : HTMLElement ;
3333 private buttons : HTMLElement [ ] | undefined ;
34+ private readonly msgBox : HTMLElement ;
3435
3536 private actionEmitter = new Emitter < IDialogAction > ( ) ;
3637 public onAction = this . actionEmitter . event ;
3738
3839 public constructor ( private readonly options : IDialogOptions ) {
39- const msgBox = document . createElement ( "div" ) ;
40- msgBox . classList . add ( "msgbox" ) ;
40+ this . msgBox = document . createElement ( "div" ) ;
41+ this . msgBox . classList . add ( "msgbox" ) ;
4142
4243 if ( this . options . message ) {
4344 const messageDiv = document . createElement ( "div" ) ;
4445 messageDiv . classList . add ( "msg" ) ;
4546 messageDiv . innerText = this . options . message ;
46- msgBox . appendChild ( messageDiv ) ;
47+ this . msgBox . appendChild ( messageDiv ) ;
4748 }
4849
4950 if ( this . options . detail ) {
5051 const detailDiv = document . createElement ( "div" ) ;
5152 detailDiv . classList . add ( "detail" ) ;
5253 detailDiv . innerText = this . options . detail ;
53- msgBox . appendChild ( detailDiv ) ;
54+ this . msgBox . appendChild ( detailDiv ) ;
5455 }
5556
5657 if ( this . options . input ) {
57- msgBox . classList . add ( "input" ) ;
58+ this . msgBox . classList . add ( "input" ) ;
5859 this . input = document . createElement ( "input" ) ;
5960 this . input . classList . add ( "input" ) ;
6061 this . input . value = this . options . input . value ;
@@ -67,12 +68,11 @@ export class Dialog {
6768 } ) ;
6869 }
6970 } ) ;
70- msgBox . appendChild ( this . input ) ;
71+ this . msgBox . appendChild ( this . input ) ;
7172 }
7273
7374 this . errors = document . createElement ( "div" ) ;
7475 this . errors . classList . add ( "errors" ) ;
75- msgBox . appendChild ( this . errors ) ;
7676
7777 if ( this . options . buttons && this . options . buttons . length > 0 ) {
7878 this . buttons = this . options . buttons . map ( ( buttonText , buttonIndex ) => {
@@ -92,12 +92,12 @@ export class Dialog {
9292 const buttonWrapper = document . createElement ( "div" ) ;
9393 buttonWrapper . classList . add ( "button-wrapper" ) ;
9494 this . buttons . forEach ( ( b ) => buttonWrapper . appendChild ( b ) ) ;
95- msgBox . appendChild ( buttonWrapper ) ;
95+ this . msgBox . appendChild ( buttonWrapper ) ;
9696 }
9797
9898 this . overlay = document . createElement ( "div" ) ;
9999 this . overlay . className = "msgbox-overlay" ;
100- this . overlay . appendChild ( msgBox ) ;
100+ this . overlay . appendChild ( this . msgBox ) ;
101101
102102 setTimeout ( ( ) => {
103103 this . overlay . style . opacity = "1" ;
@@ -122,6 +122,7 @@ export class Dialog {
122122 const errorDiv = document . createElement ( "error" ) ;
123123 errorDiv . innerText = error ;
124124 this . errors . appendChild ( errorDiv ) ;
125+ this . msgBox . appendChild ( this . errors ) ;
125126 }
126127 }
127128
@@ -131,7 +132,7 @@ export class Dialog {
131132 public show ( ) : void {
132133 if ( ! this . cachedActiveElement ) {
133134 this . cachedActiveElement = document . activeElement as HTMLElement ;
134- document . body . appendChild ( this . overlay ) ;
135+ ( document . getElementById ( "workbench.main.container" ) || document . body ) . appendChild ( this . overlay ) ;
135136 document . addEventListener ( "keydown" , this . onKeydown ) ;
136137 if ( this . input ) {
137138 this . input . focus ( ) ;
0 commit comments