Skip to content

Commit

Permalink
fix(ui5-input): fix scrolling item into view (#1848)
Browse files Browse the repository at this point in the history
The scroll container should be awaited before we use it. Additionally, we use the step constant in the "isIteminView" method to avoid half visible items, because previously the input used to scroll if the item is entirely out of view (60 is the maximum height of a standard list item).

FIXES: #1847
  • Loading branch information
ilhan007 authored Jun 22, 2020
1 parent f3d9459 commit 5438c66
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/main/src/features/InputSuggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,13 @@ class Suggestions {
const rectInput = this._getComponent().getDomRef().getBoundingClientRect();
const windowHeight = (window.innerHeight || document.documentElement.clientHeight);

return (rectItem.top <= windowHeight) && (rectItem.top >= rectInput.top);
return (rectItem.top + Suggestions.SCROLL_STEP <= windowHeight) && (rectItem.top >= rectInput.top);
}

_scrollItemIntoView(item) {
const pos = item.getDomRef().offsetTop - Suggestions.SCROLL_STEP;
this._getScrollContainer().scrollTop = pos;
async _scrollItemIntoView(item) {
const pos = item.getDomRef().offsetTop;
const scrollContainer = await this._getScrollContainer();
scrollContainer.scrollTop = pos;
}

async _getScrollContainer() {
Expand Down Expand Up @@ -338,7 +339,7 @@ class Suggestions {
}
}

Suggestions.SCROLL_STEP = 48;
Suggestions.SCROLL_STEP = 60;

// The List and Popover components would be rendered
// by the issuer component`s template.
Expand Down

0 comments on commit 5438c66

Please sign in to comment.