@@ -5,23 +5,23 @@ const isFocusTrap = el => {
55 return el . hasAttribute ( "data-ui5-focus-trap" ) ;
66} ;
77
8- const getFirstFocusableElement = container => {
8+ const getFirstFocusableElement = async container => {
99 if ( ! container || isNodeHidden ( container ) ) {
1010 return null ;
1111 }
1212
1313 return findFocusableElement ( container , true ) ;
1414} ;
1515
16- const getLastFocusableElement = container => {
16+ const getLastFocusableElement = async container => {
1717 if ( ! container || isNodeHidden ( container ) ) {
1818 return null ;
1919 }
2020
2121 return findFocusableElement ( container , false ) ;
2222} ;
2323
24- const findFocusableElement = ( container , forward ) => {
24+ const findFocusableElement = async ( container , forward ) => {
2525 let child ;
2626
2727 if ( container . shadowRoot ) {
@@ -35,10 +35,15 @@ const findFocusableElement = (container, forward) => {
3535
3636 let focusableDescendant ;
3737
38+ /* eslint-disable no-await-in-loop */
39+
3840 while ( child ) {
3941 const originalChild = child ;
4042
41- child = child . isUI5Element ? child . getFocusDomRef ( ) : child ;
43+ if ( child . isUI5Element ) {
44+ child = await child . getFocusDomRefAsync ( ) ;
45+ }
46+
4247 if ( ! child ) {
4348 return null ;
4449 }
@@ -48,7 +53,7 @@ const findFocusableElement = (container, forward) => {
4853 return ( child && typeof child . focus === "function" ) ? child : null ;
4954 }
5055
51- focusableDescendant = findFocusableElement ( child , forward ) ;
56+ focusableDescendant = await findFocusableElement ( child , forward ) ;
5257 if ( focusableDescendant ) {
5358 return ( focusableDescendant && typeof focusableDescendant . focus === "function" ) ? focusableDescendant : null ;
5459 }
@@ -57,6 +62,8 @@ const findFocusableElement = (container, forward) => {
5762 child = forward ? originalChild . nextSibling : originalChild . previousSibling ;
5863 }
5964
65+ /* eslint-enable no-await-in-loop */
66+
6067 return null ;
6168} ;
6269
0 commit comments