File tree 5 files changed +78
-2
lines changed
5 files changed +78
-2
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,10 @@ class Dialog extends Popup {
187
187
return true ;
188
188
}
189
189
190
+ get shouldHideBackdrop ( ) { // Required by Popup.js
191
+ return false ;
192
+ }
193
+
190
194
get _ariaLabelledBy ( ) { // Required by Popup.js
191
195
return this . ariaLabel ? undefined : "ui5-popup-header" ;
192
196
}
Original file line number Diff line number Diff line change @@ -106,6 +106,17 @@ const metadata = {
106
106
type : Boolean ,
107
107
} ,
108
108
109
+ /**
110
+ * Defines whether the block layer will be shown if modal property is set to true.
111
+ * @type {boolean }
112
+ * @defaultvalue false
113
+ * @public
114
+ * @since 1.0.0-rc.10
115
+ */
116
+ hideBackdrop : {
117
+ type : Boolean ,
118
+ } ,
119
+
109
120
/**
110
121
* Determines whether the <code>ui5-popover</code> arrow is hidden.
111
122
*
@@ -620,6 +631,10 @@ class Popover extends Popup {
620
631
return this . modal ;
621
632
}
622
633
634
+ get shouldHideBackdrop ( ) { // Required by Popup.js
635
+ return this . hideBackdrop ;
636
+ }
637
+
623
638
get _ariaLabelledBy ( ) { // Required by Popup.js
624
639
return this . ariaLabel ? undefined : "ui5-popup-header" ;
625
640
}
Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ const metadata = {
67
67
* Defines the aria-label attribute for the popup
68
68
*
69
69
* @type {String }
70
- * @defaultvalue : ""
70
+ * @defaultvalue ""
71
71
* @private
72
72
* @since 1.0.0-rc.8
73
73
*/
@@ -313,7 +313,7 @@ class Popup extends UI5Element {
313
313
return ;
314
314
}
315
315
316
- if ( this . isModal ) {
316
+ if ( this . isModal && ! this . shouldHideBackdrop ) {
317
317
// create static area item ref for block layer
318
318
this . getStaticAreaItemDomRef ( ) ;
319
319
this . _blockLayerHidden = false ;
@@ -430,6 +430,15 @@ class Popup extends UI5Element {
430
430
*/
431
431
get isModal ( ) { } // eslint-disable-line
432
432
433
+ /**
434
+ * Implement this getter with relevant logic in order to hide the block layer (f.e. based on a public property)
435
+ *
436
+ * @protected
437
+ * @abstract
438
+ * @returns {boolean }
439
+ */
440
+ get shouldHideBackdrop ( ) { } // eslint-disable-line
441
+
433
442
/**
434
443
* Return the ID of an element in the shadow DOM that is going to label this popup
435
444
*
Original file line number Diff line number Diff line change 171
171
</ div >
172
172
</ ui5-popover >
173
173
174
+ < ui5-button id ="btnPopModalNoLayer "> Opens modal popover with no block layer!</ ui5-button >
175
+
176
+ < ui5-popover id ="modalPopoverNoLayer " modal header-text ="Modal popover " hide-backdrop >
177
+ < ui5-list >
178
+ < ui5-li > Hello</ ui5-li >
179
+ < ui5-li > Again</ ui5-li >
180
+ < ui5-li > Wooooooooooooooooooooooooooooorld</ ui5-li >
181
+ </ ui5-list >
182
+
183
+ < div slot ="footer ">
184
+ < ui5-button id ="modalPopoverNoLayerClose "> Close</ ui5-button >
185
+ </ div >
186
+ </ ui5-popover >
187
+
174
188
< ui5-button id ="btnPopFocus "> Opens popover with initial focus!</ ui5-button >
175
189
176
190
< ui5-popover id ="popFocus " initial-focus ="focusMe " header-text ="Popover header ">
374
388
modalPopover . openBy ( btnPopModal ) ;
375
389
} ) ;
376
390
391
+ btnPopModalNoLayer . addEventListener ( "click" , function ( ) {
392
+ modalPopoverNoLayer . openBy ( btnPopModalNoLayer ) ;
393
+ } ) ;
394
+
395
+ modalPopoverNoLayerClose . addEventListener ( "click" , function ( ) {
396
+ modalPopoverNoLayer . close ( ) ;
397
+ } ) ;
398
+
377
399
modalPopoverClose . addEventListener ( "click" , function ( event ) {
378
400
modalPopover . close ( ) ;
379
401
} ) ;
Original file line number Diff line number Diff line change @@ -137,6 +137,32 @@ describe("Popover general interaction", () => {
137
137
assert . ok ( ! popover . isDisplayedInViewport ( ) , "Popover is closed." ) ;
138
138
} ) ;
139
139
140
+ it ( "tests modal popover with no block layer" , ( ) => {
141
+ const btnOpenPopover = $ ( "#btnPopModalNoLayer" ) ;
142
+ const popover = $ ( "#modalPopoverNoLayer" ) ;
143
+ const popoverId = popover . getProperty ( "_id" ) ;
144
+
145
+ btnOpenPopover . click ( ) ;
146
+ assert . ok ( popover . getProperty ( "opened" ) , "Popover is opened." ) ;
147
+
148
+ const blockLayerIsCreated = browser . execute ( ( popoverId ) => {
149
+ const staticAreaItems = document . querySelectorAll ( "ui5-static-area-item" ) ;
150
+ let result = false ;
151
+
152
+ staticAreaItems . forEach ( item => {
153
+ if ( item . shadowRoot . querySelector ( ".ui5-block-layer" ) && item . classList . contains ( popoverId ) ) {
154
+ result = true ;
155
+ }
156
+ } ) ;
157
+
158
+ return result
159
+ } , popoverId ) ;
160
+
161
+ assert . notOk ( blockLayerIsCreated , "Block layer is not created." ) ;
162
+
163
+ browser . keys ( "Escape" ) ;
164
+ } ) ;
165
+
140
166
it ( "tests initial focus" , ( ) => {
141
167
const focusedButton = $ ( "#focusMe" ) ;
142
168
const btnOpenPopover = $ ( "#btnPopFocus" ) ;
You can’t perform that action at this time.
0 commit comments