File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -816,6 +816,19 @@ class Select extends UI5Element implements IFormElement {
816
816
this . _toggleRespPopover ( ) ;
817
817
}
818
818
819
+ _scrollSelectedItem ( ) {
820
+ if ( this . _isPickerOpen ) {
821
+ const itemRef = this . _currentlySelectedOption . getDomRef ( ) ;
822
+ if ( itemRef ) {
823
+ itemRef . scrollIntoView ( {
824
+ behavior : "auto" ,
825
+ block : "nearest" ,
826
+ inline : "nearest" ,
827
+ } ) ;
828
+ }
829
+ }
830
+ }
831
+
819
832
_handleArrowNavigation ( e : KeyboardEvent ) {
820
833
let nextIndex = - 1 ;
821
834
const currentIndex = this . _selectedIndex ;
@@ -835,6 +848,7 @@ class Select extends UI5Element implements IFormElement {
835
848
// The aria-activedescendents attribute can't be used,
836
849
// because listitem elements are in different shadow dom
837
850
this . itemSelectionAnnounce ( ) ;
851
+ this . _scrollSelectedItem ( ) ;
838
852
}
839
853
}
840
854
@@ -882,6 +896,7 @@ class Select extends UI5Element implements IFormElement {
882
896
this . opened = true ;
883
897
this . fireEvent < CustomEvent > ( "open" ) ;
884
898
this . itemSelectionAnnounce ( ) ;
899
+ this . _scrollSelectedItem ( ) ;
885
900
}
886
901
887
902
_afterClose ( ) {
Original file line number Diff line number Diff line change @@ -540,6 +540,24 @@ describe("Select general interaction", () => {
540
540
await firstItem . click ( ) ;
541
541
assert . notOk ( await popover . getProperty ( "opened" ) , "Select is closed." ) ;
542
542
} ) ;
543
+
544
+ it ( "Tests if currently selected option is visible in the viewport when keyboard navigation is used" , async ( ) => {
545
+ await browser . setWindowSize ( 600 , 100 ) ;
546
+
547
+ const select = await browser . $ ( "#warningSelect" ) ;
548
+ const staticAreaItemClassName = await browser . getStaticAreaItemClassName ( "#warningSelect" ) ;
549
+ const popover = await browser . $ ( `.${ staticAreaItemClassName } ` ) . shadow$ ( "ui5-responsive-popover" ) ;
550
+
551
+ await select . click ( ) ;
552
+ assert . ok ( await popover . getProperty ( "opened" ) , "Select is opened." ) ;
553
+
554
+ await select . keys ( "ArrowDown" ) ;
555
+ await select . keys ( "ArrowDown" ) ;
556
+ await select . keys ( "ArrowDown" ) ;
557
+
558
+ const selectedOption = await popover . $ ( "ui5-list" ) . $ ( "ui5-li[selected]" ) ;
559
+ assert . ok ( await selectedOption . isClickable ( ) , "Selected option is visible in the viewport." ) ;
560
+ } ) ;
543
561
} ) ;
544
562
545
563
describe ( "Attributes propagation" , ( ) => {
You can’t perform that action at this time.
0 commit comments