From ba7049dd0f93dfe5ca8ffed8c8d79d255c8a80cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 8 Nov 2019 09:57:32 +0100 Subject: [PATCH] Templating: highlight first item when searching a variable dropdown (#20264) --- public/app/core/directives/value_select_dropdown.ts | 2 +- public/app/core/specs/value_select_dropdown.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/app/core/directives/value_select_dropdown.ts b/public/app/core/directives/value_select_dropdown.ts index 65e0d6137d9..df9911b8728 100644 --- a/public/app/core/directives/value_select_dropdown.ts +++ b/public/app/core/directives/value_select_dropdown.ts @@ -279,7 +279,7 @@ export class ValueSelectDropdownCtrl { } updateUIBoundOptions($scope: IScope, options: any[]) { - this.highlightIndex = -1; + this.highlightIndex = 0; this.search.options = options.slice(0, Math.min(options.length, 1000)); $scope.$apply(); } diff --git a/public/app/core/specs/value_select_dropdown.test.ts b/public/app/core/specs/value_select_dropdown.test.ts index 48c867f5792..2f8f24c017f 100644 --- a/public/app/core/specs/value_select_dropdown.test.ts +++ b/public/app/core/specs/value_select_dropdown.test.ts @@ -253,8 +253,8 @@ describe('updateUIBoundOptions', () => { ctrl.updateUIBoundOptions($scope, options); }); - it('then highlightIndex should be reset', () => { - expect(ctrl.highlightIndex).toEqual(-1); + it('then highlightIndex should be reset to first item', () => { + expect(ctrl.highlightIndex).toEqual(0); }); it('then search.options should be same as options but capped to 1000', () => {