Skip to content

Commit

Permalink
fix: dropdown scroll fixed (#2333)
Browse files Browse the repository at this point in the history
  • Loading branch information
tshimber authored Aug 29, 2024
1 parent 8a694a2 commit 592c69d
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class DropdownSelect {
@State() hasFocus: boolean = false;

private comboEl: HTMLElement;
private listboxEl: HTMLElement;
private scrollContainer: HTMLElement;
private listboxPadEl: HTMLElement;
private hiddenInput: HTMLInputElement;

Expand Down Expand Up @@ -346,10 +346,10 @@ export class DropdownSelect {

bringIntoView(index) {
const options: NodeListOf<HTMLElement> =
this.listboxEl.querySelectorAll('[role=option]');
this.scrollContainer.querySelectorAll('[role=option]');

if (hasOverflow(this.listboxEl)) {
keepInView(options[index], this.listboxEl);
if (hasOverflow(this.scrollContainer)) {
keepInView(options[index], this.scrollContainer);
}

if (!isInView(options[index])) {
Expand Down Expand Up @@ -530,13 +530,13 @@ export class DropdownSelect {
</div>
<div part="listbox-pad" ref={(el) => (this.listboxPadEl = el)}>
<div
ref={(el) => (this.scrollContainer = el)}
part="listbox-scroll-container"
onMouseDown={(e) => {
e.preventDefault();
}}
>
<div
ref={(el) => (this.listboxEl = el)}
part="listbox"
role="listbox"
id={`${this.comboboxId}-listbox`}
Expand Down

0 comments on commit 592c69d

Please sign in to comment.