File tree 4 files changed +20
-7
lines changed
4 files changed +20
-7
lines changed Original file line number Diff line number Diff line change 1
1
import isNodeHidden from "./isNodeHidden.js" ;
2
2
import isNodeClickable from "./isNodeClickable.js" ;
3
3
4
+ const isFocusTrap = el => {
5
+ return el . hasAttribute ( "data-ui5-focus-trap" ) ;
6
+ } ;
7
+
4
8
const getFirstFocusableElement = container => {
5
9
if ( ! container || isNodeHidden ( container ) ) {
6
10
return null ;
@@ -19,7 +23,10 @@ const getLastFocusableElement = container => {
19
23
20
24
const findFocusableElement = ( container , forward ) => {
21
25
let child ;
22
- if ( container . assignedNodes && container . assignedNodes ( ) ) {
26
+
27
+ if ( container . shadowRoot ) {
28
+ child = forward ? container . shadowRoot . firstChild : container . shadowRoot . lastChild ;
29
+ } else if ( container . assignedNodes && container . assignedNodes ( ) ) {
23
30
const assignedElements = container . assignedNodes ( ) ;
24
31
child = forward ? assignedElements [ 0 ] : assignedElements [ assignedElements . length - 1 ] ;
25
32
} else {
@@ -36,7 +43,7 @@ const findFocusableElement = (container, forward) => {
36
43
return null ;
37
44
}
38
45
39
- if ( child . nodeType === 1 && ! isNodeHidden ( child ) ) {
46
+ if ( child . nodeType === 1 && ! isNodeHidden ( child ) && ! isFocusTrap ( child ) ) {
40
47
if ( isNodeClickable ( child ) ) {
41
48
return ( child && typeof child . focus === "function" ) ? child : null ;
42
49
}
Original file line number Diff line number Diff line change 2
2
3
3
{{> beforeHeader }}
4
4
5
- <span class =" first-fe" tabindex =" 0" @focusin ={{ forwardToLast }} ></span >
5
+ <span class =" first-fe" data-ui5-focus-trap tabindex =" 0" @focusin ={{ forwardToLast }} ></span >
6
6
7
7
{{> header }}
8
8
12
12
13
13
{{> footer }}
14
14
15
- <span class =" last-fe" tabindex =" 0" @focusin ={{ forwardToFirst }} ></span >
15
+ <span class =" last-fe" data-ui5-focus-trap tabindex =" 0" @focusin ={{ forwardToFirst }} ></span >
16
16
17
17
</section >
18
18
Original file line number Diff line number Diff line change @@ -311,11 +311,11 @@ class Popup extends UI5Element {
311
311
}
312
312
313
313
/**
314
- * Sets "inline- block" display to the popup
314
+ * Sets "block" display to the popup
315
315
* @protected
316
316
*/
317
317
show ( ) {
318
- this . style . display = "inline- block" ;
318
+ this . style . display = "block" ;
319
319
}
320
320
321
321
Original file line number Diff line number Diff line change 37
37
< ui5-button id ="modals-open "> Open Multiple modals</ ui5-button >
38
38
< br >
39
39
< br >
40
+ < ui5-button id ="empty-open "> Open empty dialog (no focusable element)</ ui5-button >
41
+ < br > < br >
40
42
41
43
< ui5-block-layer > </ ui5-block-layer >
42
44
198
200
</ ui5-list >
199
201
</ ui5-popover >
200
202
203
+ < ui5-dialog id ="empty-dialog "> Empty</ ui5-dialog >
204
+
201
205
< script >
202
206
203
207
let preventClosing = true ;
248
252
bigDanger . addEventListener ( 'click' , function ( event ) {
249
253
bigDangerPop . openBy ( bigDanger ) ;
250
254
} ) ;
255
+
256
+ window [ "empty-open" ] . addEventListener ( "click" , function ( event ) { window [ "empty-dialog" ] . open ( ) ; } ) ;
251
257
</ script >
252
258
</ body >
253
259
254
- </ html >
260
+ </ html >
You can’t perform that action at this time.
0 commit comments