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 @@ -138,6 +138,28 @@ describe('Key managers', () => {
138138 expect ( fakeKeyEvents . unsupported . defaultPrevented ) . toBe ( false ) ;
139139 } ) ;
140140
141+ it ( 'should ignore the horizontal keys when only in vertical mode' , ( ) => {
142+ keyManager . withVerticalOrientation ( ) . withHorizontalOrientation ( null ) ;
143+
144+ expect ( keyManager . activeItemIndex ) . toBe ( 0 ) ;
145+
146+ keyManager . onKeydown ( fakeKeyEvents . rightArrow ) ;
147+
148+ expect ( keyManager . activeItemIndex ) . toBe ( 0 ) ;
149+ expect ( fakeKeyEvents . rightArrow . defaultPrevented ) . toBe ( false ) ;
150+ } ) ;
151+
152+ it ( 'should ignore the horizontal keys when only in horizontal mode' , ( ) => {
153+ keyManager . withVerticalOrientation ( false ) . withHorizontalOrientation ( 'ltr' ) ;
154+
155+ expect ( keyManager . activeItemIndex ) . toBe ( 0 ) ;
156+
157+ keyManager . onKeydown ( fakeKeyEvents . downArrow ) ;
158+
159+ expect ( keyManager . activeItemIndex ) . toBe ( 0 ) ;
160+ expect ( fakeKeyEvents . downArrow . defaultPrevented ) . toBe ( false ) ;
161+ } ) ;
162+
141163 describe ( 'with `vertical` direction' , ( ) => {
142164 beforeEach ( ( ) => {
143165 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