@@ -31,30 +31,31 @@ export class Dialog {
31
31
private input : HTMLInputElement | undefined ;
32
32
private errors : HTMLElement ;
33
33
private buttons : HTMLElement [ ] | undefined ;
34
+ private readonly msgBox : HTMLElement ;
34
35
35
36
private actionEmitter = new Emitter < IDialogAction > ( ) ;
36
37
public onAction = this . actionEmitter . event ;
37
38
38
39
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" ) ;
41
42
42
43
if ( this . options . message ) {
43
44
const messageDiv = document . createElement ( "div" ) ;
44
45
messageDiv . classList . add ( "msg" ) ;
45
46
messageDiv . innerText = this . options . message ;
46
- msgBox . appendChild ( messageDiv ) ;
47
+ this . msgBox . appendChild ( messageDiv ) ;
47
48
}
48
49
49
50
if ( this . options . detail ) {
50
51
const detailDiv = document . createElement ( "div" ) ;
51
52
detailDiv . classList . add ( "detail" ) ;
52
53
detailDiv . innerText = this . options . detail ;
53
- msgBox . appendChild ( detailDiv ) ;
54
+ this . msgBox . appendChild ( detailDiv ) ;
54
55
}
55
56
56
57
if ( this . options . input ) {
57
- msgBox . classList . add ( "input" ) ;
58
+ this . msgBox . classList . add ( "input" ) ;
58
59
this . input = document . createElement ( "input" ) ;
59
60
this . input . classList . add ( "input" ) ;
60
61
this . input . value = this . options . input . value ;
@@ -67,12 +68,11 @@ export class Dialog {
67
68
} ) ;
68
69
}
69
70
} ) ;
70
- msgBox . appendChild ( this . input ) ;
71
+ this . msgBox . appendChild ( this . input ) ;
71
72
}
72
73
73
74
this . errors = document . createElement ( "div" ) ;
74
75
this . errors . classList . add ( "errors" ) ;
75
- msgBox . appendChild ( this . errors ) ;
76
76
77
77
if ( this . options . buttons && this . options . buttons . length > 0 ) {
78
78
this . buttons = this . options . buttons . map ( ( buttonText , buttonIndex ) => {
@@ -92,12 +92,12 @@ export class Dialog {
92
92
const buttonWrapper = document . createElement ( "div" ) ;
93
93
buttonWrapper . classList . add ( "button-wrapper" ) ;
94
94
this . buttons . forEach ( ( b ) => buttonWrapper . appendChild ( b ) ) ;
95
- msgBox . appendChild ( buttonWrapper ) ;
95
+ this . msgBox . appendChild ( buttonWrapper ) ;
96
96
}
97
97
98
98
this . overlay = document . createElement ( "div" ) ;
99
99
this . overlay . className = "msgbox-overlay" ;
100
- this . overlay . appendChild ( msgBox ) ;
100
+ this . overlay . appendChild ( this . msgBox ) ;
101
101
102
102
setTimeout ( ( ) => {
103
103
this . overlay . style . opacity = "1" ;
@@ -122,6 +122,7 @@ export class Dialog {
122
122
const errorDiv = document . createElement ( "error" ) ;
123
123
errorDiv . innerText = error ;
124
124
this . errors . appendChild ( errorDiv ) ;
125
+ this . msgBox . appendChild ( this . errors ) ;
125
126
}
126
127
}
127
128
@@ -131,7 +132,7 @@ export class Dialog {
131
132
public show ( ) : void {
132
133
if ( ! this . cachedActiveElement ) {
133
134
this . cachedActiveElement = document . activeElement as HTMLElement ;
134
- document . body . appendChild ( this . overlay ) ;
135
+ ( document . getElementById ( "workbench.main.container" ) || document . body ) . appendChild ( this . overlay ) ;
135
136
document . addEventListener ( "keydown" , this . onKeydown ) ;
136
137
if ( this . input ) {
137
138
this . input . focus ( ) ;
0 commit comments