File tree 2 files changed +30
-0
lines changed 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,28 @@ describe('Key managers', () => {
138
138
expect ( fakeKeyEvents . unsupported . defaultPrevented ) . toBe ( false ) ;
139
139
} ) ;
140
140
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
+
141
163
describe ( 'with `vertical` direction' , ( ) => {
142
164
beforeEach ( ( ) => {
143
165
keyManager . withVerticalOrientation ( ) ;
Original file line number Diff line number Diff line change @@ -171,12 +171,16 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
171
171
if ( this . _vertical ) {
172
172
this . setNextItemActive ( ) ;
173
173
break ;
174
+ } else {
175
+ return ;
174
176
}
175
177
176
178
case UP_ARROW :
177
179
if ( this . _vertical ) {
178
180
this . setPreviousItemActive ( ) ;
179
181
break ;
182
+ } else {
183
+ return ;
180
184
}
181
185
182
186
case RIGHT_ARROW :
@@ -186,6 +190,8 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
186
190
} else if ( this . _horizontal === 'rtl' ) {
187
191
this . setPreviousItemActive ( ) ;
188
192
break ;
193
+ } else {
194
+ return ;
189
195
}
190
196
191
197
case LEFT_ARROW :
@@ -195,6 +201,8 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
195
201
} else if ( this . _horizontal === 'rtl' ) {
196
202
this . setNextItemActive ( ) ;
197
203
break ;
204
+ } else {
205
+ return ;
198
206
}
199
207
200
208
default :
You can’t perform that action at this time.
0 commit comments