Skip to content

Commit 4028004

Browse files
committed
Scrollable fixes in the Select dropdown
1 parent 4d6106b commit 4028004

2 files changed

Lines changed: 9 additions & 15 deletions

File tree

src/includes/vscode-select/styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export default [
192192
.scrollable {
193193
display: block;
194194
max-height: 222px;
195-
margin: 0;
195+
margin: 1px 0;
196196
overflow: hidden;
197197
}
198198
@@ -201,7 +201,7 @@ export default [
201201
cursor: pointer;
202202
list-style: none;
203203
margin: 0;
204-
padding: 1px;
204+
padding: 0 1px;
205205
}
206206
207207
.option {

src/includes/vscode-select/vscode-select-base.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import {html, render, nothing, TemplateResult, PropertyValues} from 'lit';
2-
import {
3-
eventOptions,
4-
property,
5-
queryAssignedElements,
6-
state,
7-
} from 'lit/decorators.js';
2+
import {property, queryAssignedElements, state} from 'lit/decorators.js';
83
import {classMap} from 'lit/directives/class-map.js';
94
import {ifDefined} from 'lit/directives/if-defined.js';
105
import {repeat} from 'lit/directives/repeat.js';
@@ -411,10 +406,9 @@ export class VscodeSelectBase extends VscElement {
411406
}
412407
}
413408

414-
@eventOptions({passive: true})
415-
protected _onOptionListScroll(ev: Event) {
416-
this._optionListScrollPos = (ev.target as HTMLUListElement).scrollTop;
417-
}
409+
private _onOptionListScroll = (ev: CustomEvent<number>) => {
410+
this._optionListScrollPos = ev.detail;
411+
};
418412

419413
protected _onOptionMouseOver(ev: MouseEvent): void {
420414
if (this._isHoverForbidden) {
@@ -749,8 +743,8 @@ export class VscodeSelectBase extends VscElement {
749743
};
750744

751745
const scrollPaneHeight = Math.min(
752-
this._opts.numOfVisibleOptions * OPT_HEIGHT + 2,
753-
VISIBLE_OPTS * OPT_HEIGHT + 2
746+
this._opts.numOfVisibleOptions * OPT_HEIGHT,
747+
VISIBLE_OPTS * OPT_HEIGHT
754748
);
755749

756750
return html`
@@ -760,7 +754,7 @@ export class VscodeSelectBase extends VscElement {
760754
always-visible
761755
class="scrollable"
762756
tabindex="-1"
763-
@scroll=${this._onOptionListScroll}
757+
@vsc-scrollable-change=${this._onOptionListScroll}
764758
.scrollPos=${this._optionListScrollPos}
765759
.style=${stylePropertyMap({height: `${scrollPaneHeight}px`})}
766760
>

0 commit comments

Comments
 (0)