@@ -148,8 +148,17 @@ function createBLyBackStyle() {
148
148
149
149
customBLyBackStyleInserted = true ;
150
150
151
- const stylesheet = document . styleSheets [ 0 ] ;
152
- stylesheet . insertRule ( ".sapUiBLyBack {overflow: hidden;position: fixed;width:100%;height: 100%;}" , 0 ) ;
151
+ const bodyStyleSheet = document . createElement ( "style" ) ;
152
+ bodyStyleSheet . type = "text/css" ;
153
+ bodyStyleSheet . innerHTML = `
154
+ .sapUiBLyBack {
155
+ width: 100%;
156
+ height: 100%;
157
+ position: fixed;
158
+ overflow: hidden;
159
+ }
160
+ ` ;
161
+ document . head . appendChild ( bodyStyleSheet ) ;
153
162
}
154
163
155
164
function updateBlockLayers ( ) {
@@ -180,17 +189,24 @@ function updateBodyScrolling(hasModal) {
180
189
createBLyBackStyle ( ) ;
181
190
182
191
if ( hasModal ) {
183
- document . body . style . top = `-${ window . pageYOffset } px` ;
184
- document . body . classList . add ( "sapUiBLyBack" ) ;
192
+ addBodyStyles ( ) ;
185
193
} else {
186
- document . body . classList . remove ( "sapUiBLyBack" ) ;
187
- window . scrollTo ( 0 , - parseFloat ( document . body . style . top ) ) ;
188
- document . body . style . top = "" ;
194
+ removeBodyStyles ( ) ;
189
195
}
190
-
191
196
isBodyScrollingDisabled = hasModal ;
192
197
}
193
198
199
+ function addBodyStyles ( ) {
200
+ document . body . style . top = `-${ window . pageYOffset } px` ;
201
+ document . body . classList . add ( "sapUiBLyBack" ) ;
202
+ }
203
+
204
+ function removeBodyStyles ( ) {
205
+ document . body . classList . remove ( "sapUiBLyBack" ) ;
206
+ window . scrollTo ( 0 , - parseFloat ( document . body . style . top ) ) ;
207
+ document . body . style . top = "" ;
208
+ }
209
+
194
210
/**
195
211
* @class
196
212
* <h3 class="comment-api-title">Overview</h3>
@@ -422,6 +438,10 @@ class Popup extends UI5Element {
422
438
423
439
this . _lastFocusableElement = null ;
424
440
}
441
+
442
+ onExitDOM ( ) {
443
+ removeBodyStyles ( ) ;
444
+ }
425
445
}
426
446
427
447
export default Popup ;
0 commit comments