Skip to content

Commit 8396bad

Browse files
authored
Add support for disabling scrollIntoView (#85)
1 parent 3a806d6 commit 8396bad

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ behavior of the omnibox:
218218
determines the value of AlignToTop that is given into scrollIntoView() when scrolling Omnibox
219219
suggestions into view. Defaults to false. It's useful to configure this when using the Omnibox
220220
inside of a scrollable container.
221+
- `shouldScrollIntoView {Boolean}`: An expression that should evaluate to a Boolean that
222+
determines whether to scroll suggestions into view at all. Defaults to true.
221223

222224
## Omnibox Event Bindings
223225

src/angularComponent/ngcOmniboxComponent.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ import NgcOmniboxController from './ngcOmniboxController.js';
4242
* determines the value of AlignToTop that is given into scrollIntoView() when scrolling
4343
* Omnibox suggestions into view. Defaults to false. It's useful to configure this when
4444
* using the Omnibox inside of a scrollable container.
45+
* - `shouldScrollIntoView {Boolean}`: An expression that should evaluate to a Boolean that
46+
* determines whether to scroll suggestions into view at all. Defaults to true.
4547
*
4648
* The component has no template, all content that does not map to one of the sub-components will
4749
* be displayed in the final output as-is and un-modified.
@@ -74,6 +76,7 @@ export default {
7476
onUnchosen: '&',
7577
onShowSuggestions: '&',
7678
onHideSuggestions: '&',
77-
scrollIntoViewAlignToTop: '<?'
79+
scrollIntoViewAlignToTop: '<?',
80+
shouldScrollIntoView: '<?'
7881
}
7982
};

src/angularComponent/ngcOmniboxController.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,9 @@ export default class NgcOmniboxController {
726726
}
727727

728728
_scrollSuggestionIntoView() {
729+
if (this.shouldScrollIntoView === false) {
730+
return;
731+
}
729732
// Disable highlighting while scrolling so the mouse doesn't accidentally highlight a new item
730733
this.isHighlightingDisabled = true;
731734

0 commit comments

Comments
 (0)