File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -139,6 +139,28 @@ describe('Key managers', () => {
139139 expect ( fakeKeyEvents . unsupported . defaultPrevented ) . toBe ( false ) ;
140140 } ) ;
141141
142+ it ( 'should ignore the horizontal keys when only in vertical mode' , ( ) => {
143+ keyManager . withVerticalOrientation ( ) . withHorizontalOrientation ( null ) ;
144+
145+ expect ( keyManager . activeItemIndex ) . toBe ( 0 ) ;
146+
147+ keyManager . onKeydown ( fakeKeyEvents . rightArrow ) ;
148+
149+ expect ( keyManager . activeItemIndex ) . toBe ( 0 ) ;
150+ expect ( fakeKeyEvents . rightArrow . defaultPrevented ) . toBe ( false ) ;
151+ } ) ;
152+
153+ it ( 'should ignore the horizontal keys when only in horizontal mode' , ( ) => {
154+ keyManager . withVerticalOrientation ( false ) . withHorizontalOrientation ( 'ltr' ) ;
155+
156+ expect ( keyManager . activeItemIndex ) . toBe ( 0 ) ;
157+
158+ keyManager . onKeydown ( fakeKeyEvents . downArrow ) ;
159+
160+ expect ( keyManager . activeItemIndex ) . toBe ( 0 ) ;
161+ expect ( fakeKeyEvents . downArrow . defaultPrevented ) . toBe ( false ) ;
162+ } ) ;
163+
142164 describe ( 'with `vertical` direction' , ( ) => {
143165 beforeEach ( ( ) => {
144166 keyManager . withVerticalOrientation ( ) ;
Original file line number Diff line number Diff line change @@ -171,12 +171,16 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
171171 if ( this . _vertical ) {
172172 this . setNextItemActive ( ) ;
173173 break ;
174+ } else {
175+ return ;
174176 }
175177
176178 case UP_ARROW :
177179 if ( this . _vertical ) {
178180 this . setPreviousItemActive ( ) ;
179181 break ;
182+ } else {
183+ return ;
180184 }
181185
182186 case RIGHT_ARROW :
@@ -186,6 +190,8 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
186190 } else if ( this . _horizontal === 'rtl' ) {
187191 this . setPreviousItemActive ( ) ;
188192 break ;
193+ } else {
194+ return ;
189195 }
190196
191197 case LEFT_ARROW :
@@ -195,6 +201,8 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
195201 } else if ( this . _horizontal === 'rtl' ) {
196202 this . setNextItemActive ( ) ;
197203 break ;
204+ } else {
205+ return ;
198206 }
199207
200208 default :
You can’t perform that action at this time.
0 commit comments