File tree 1 file changed +25
-14
lines changed
1 file changed +25
-14
lines changed Original file line number Diff line number Diff line change 245
245
246
246
case keyCode . ENTER :
247
247
case keyCode . NUMPAD_ENTER :
248
- suggestList = event . currentTarget . parentNode . getElementsByTagName ( 'ul' ) [ 0 ] ;
249
- hasSelectedItems = suggestList . getElementsByClassName ( '_active' ) . length >= 0 ;
250
-
251
- if ( hasSelectedItems ) {
252
- selectedItem = $ ( suggestList . getElementsByClassName ( '_active' ) [ 0 ] ) ;
253
- /* eslint-disable max-depth */
254
- if ( selectedItem . find ( 'a' ) && selectedItem . find ( 'a' ) . attr ( 'href' ) !== undefined ) {
255
- window . location = selectedItem . find ( 'a' ) . attr ( 'href' ) ;
256
- event . preventDefault ( ) ;
257
-
258
- return false ;
259
- }
260
- /* eslint-enable max-depth */
261
- }
248
+ this . _toggleEnter ( event ) ;
262
249
263
250
if ( this . isDropdownShown ( ) && this . _focused ) {
264
251
this . _proxyEvents ( event ) ;
328
315
this . _bindDropdown ( ) ;
329
316
} ,
330
317
318
+ /**
319
+ * @param {Object } event - event object
320
+ * @private
321
+ */
322
+ _toggleEnter : function ( event ) {
323
+ var suggestList ,
324
+ activeItems ,
325
+ selectedItem ;
326
+
327
+ suggestList = $ ( event . currentTarget . parentNode ) . find ( 'ul' ) . first ( ) ;
328
+ activeItems = suggestList . find ( '._active' ) ;
329
+
330
+ if ( activeItems . length >= 0 ) {
331
+ selectedItem = activeItems . first ( ) ;
332
+
333
+ if ( selectedItem . find ( 'a' ) && selectedItem . find ( 'a' ) . attr ( 'href' ) !== undefined ) {
334
+ window . location = selectedItem . find ( 'a' ) . attr ( 'href' ) ;
335
+ event . preventDefault ( ) ;
336
+
337
+ return false ;
338
+ }
339
+ }
340
+ } ,
341
+
331
342
/**
332
343
* @param {Object } e - event object
333
344
* @private
You can’t perform that action at this time.
0 commit comments