Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions spec/tests/angularComponent/ngcOmniboxControllerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,5 +657,20 @@ describe('ngcOmnibox.angularComponent.ngcOmniboxController', () => {
omniboxController.highlightedChoice = null;
expect(omniboxController.fieldElement.focus).toHaveBeenCalled();
});

it('should call scrollSuggestionIntoView by default', () => {
const scrollSuggestionIntoViewSpy = spyOn(omniboxController, '_scrollSuggestionIntoView');
omniboxController.suggestions = ['test', 'me'];
omniboxController.highlightNextSuggestion();
expect(scrollSuggestionIntoViewSpy).toHaveBeenCalled();
});

it('should not call scrollSuggestionIntoView when shouldScrollIntoView is false', () => {
const scrollSuggestionIntoViewSpy = spyOn(omniboxController, '_scrollSuggestionIntoView');
omniboxController.shouldScrollIntoView = false;
omniboxController.suggestions = ['test', 'me'];
omniboxController.highlightNextSuggestion();
expect(scrollSuggestionIntoViewSpy).not.toHaveBeenCalled();
});
});
});
11 changes: 6 additions & 5 deletions src/angularComponent/ngcOmniboxController.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ export default class NgcOmniboxController {
return this.highlightPreviousSuggestion(startHighlightIndex);
}

this._scrollSuggestionIntoView();
if (this.shouldScrollIntoView !== false) {
this._scrollSuggestionIntoView();
}

return newIndex;
}
Expand Down Expand Up @@ -282,7 +284,9 @@ export default class NgcOmniboxController {
return this.highlightNextSuggestion(startHighlightIndex);
}

this._scrollSuggestionIntoView();
if (this.shouldScrollIntoView !== false) {
this._scrollSuggestionIntoView();
}

return newIndex;
}
Expand Down Expand Up @@ -726,9 +730,6 @@ export default class NgcOmniboxController {
}

_scrollSuggestionIntoView() {
if (this.shouldScrollIntoView === false) {
return;
}
// Disable highlighting while scrolling so the mouse doesn't accidentally highlight a new item
this.isHighlightingDisabled = true;

Expand Down