Skip to content

Commit 5438c66

Browse files
authored
fix(ui5-input): fix scrolling item into view (#1848)
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
1 parent f3d9459 commit 5438c66

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

packages/main/src/features/InputSuggestions.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,13 @@ class Suggestions {
280280
const rectInput = this._getComponent().getDomRef().getBoundingClientRect();
281281
const windowHeight = (window.innerHeight || document.documentElement.clientHeight);
282282

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

286-
_scrollItemIntoView(item) {
287-
const pos = item.getDomRef().offsetTop - Suggestions.SCROLL_STEP;
288-
this._getScrollContainer().scrollTop = pos;
286+
async _scrollItemIntoView(item) {
287+
const pos = item.getDomRef().offsetTop;
288+
const scrollContainer = await this._getScrollContainer();
289+
scrollContainer.scrollTop = pos;
289290
}
290291

291292
async _getScrollContainer() {
@@ -338,7 +339,7 @@ class Suggestions {
338339
}
339340
}
340341

341-
Suggestions.SCROLL_STEP = 48;
342+
Suggestions.SCROLL_STEP = 60;
342343

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

0 commit comments

Comments
 (0)