Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-combobox): correct scrolling behavior #9632

Merged
merged 4 commits into from
Aug 7, 2024
Merged
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
10 changes: 7 additions & 3 deletions packages/main/src/ComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ class ComboBox extends UI5Element implements IFormInputElement {
this._isValueStateFocused = false;

this._announceSelectedItem(indexOfItem);
this._scrollToItem(indexOfItem, isForward);
this._scrollToItem(indexOfItem);

if (isGroupItem && this.open) {
return;
Expand Down Expand Up @@ -1205,7 +1205,7 @@ class ComboBox extends UI5Element implements IFormInputElement {
item._isVisible = true;
}

_scrollToItem(indexOfItem: number, forward: boolean) {
_scrollToItem(indexOfItem: number) {
const picker = this._getPicker();
const list = this._getItemsList();
const listItem = list?.listItems[indexOfItem];
Expand All @@ -1216,7 +1216,11 @@ class ComboBox extends UI5Element implements IFormInputElement {
const isListItemInVisibleArea = listItemRect.top >= pickerRect.top && listItemRect.bottom <= pickerRect.bottom;

if (!isListItemInVisibleArea) {
listItem.scrollIntoView({ behavior: "instant", block: forward ? "end" : "start", inline: "nearest" });
listItem.scrollIntoView({
behavior: "auto",
block: "nearest",
inline: "nearest",
});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sample</title>
</head>
<body style="background-color: var(--sapBackgroundColor);">
<body style="background-color: var(--sapBackgroundColor); height: 100px;">
<!-- playground-fold-end -->

<ui5-textarea maxlength="10" placeholder="Enter more than 10 characters" show-exceeded-text></ui5-textarea>
Expand Down