File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
extensions/amp-selector/0.1 Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -434,7 +434,12 @@ export class AmpSelector extends AMP.BaseElement {
434
434
// The selection should loop around if the user attempts to go one
435
435
// past the beginning or end.
436
436
const previousIndex = this . elements_ . indexOf ( this . selectedElements_ [ 0 ] ) ;
437
- const index = previousIndex + delta ;
437
+
438
+ // If previousIndex === -1 is true, then a negative delta will be offset
439
+ // one more than is wanted when looping back around in the options.
440
+ // This occurs when no options are selected and "selectUp" is called.
441
+ const selectUpWhenNoneSelected = previousIndex === - 1 && delta < 0 ;
442
+ const index = selectUpWhenNoneSelected ? delta : previousIndex + delta ;
438
443
const normalizedIndex = mod ( index , this . elements_ . length ) ;
439
444
440
445
this . setSelection_ ( this . elements_ [ normalizedIndex ] ) ;
You can’t perform that action at this time.
0 commit comments