Skip to content

Commit a8dbc41

Browse files
authored
fix: properly adjust drop position only after rendering (#408)
1 parent 566242e commit a8dbc41

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

packages/multiple-select-vanilla/src/MultipleSelectInstance.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,18 +1311,18 @@ export class MultipleSelectInstance {
13111311
protected adjustDropSizeAndPosition() {
13121312
if (this.dropElm) {
13131313
if (this.options.container) {
1314-
const offset = getOffset(this.dropElm);
13151314
let container: HTMLElement;
13161315
if (this.options.container instanceof Node) {
13171316
container = this.options.container as HTMLElement;
13181317
} else if (typeof this.options.container === 'string') {
13191318
container = this.options.container === 'body' ? document.body : (document.querySelector(this.options.container) as HTMLElement);
13201319
}
13211320
container!.appendChild(this.dropElm);
1322-
this.dropElm.style.top = `${offset?.top ?? 0}px`;
1323-
this.dropElm.style.left = `${offset?.left ?? 0}px`;
1321+
const { top: offsetTop = 0, left: offsetLeft = 0 } = getOffset(this.parentElm) || {};
1322+
this.dropElm.style.top = `${offsetTop + this.parentElm.offsetHeight}px`;
1323+
this.dropElm.style.left = `${offsetLeft}px`;
1324+
this.dropElm.style.width = `${this.parentElm.offsetWidth}px`;
13241325
this.dropElm.style.minWidth = 'auto';
1325-
this.dropElm.style.width = `${getSize(this.parentElm, 'outer', 'width')}px`;
13261326
}
13271327

13281328
const minHeight = this.options.minHeight;

packages/multiple-select-vanilla/src/styles/_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ $ms-choice-bgcolor: #fff !default;
2323
$ms-choice-color: #444 !default;
2424
$ms-choice-disabled-bgcolor: #f4f4f4 !default;
2525
$ms-choice-disabled-border: 1px solid #ddd !default;
26+
$ms-choice-height: 26px !default;
2627
$ms-choice-padding: 0 6px 0 8px !default;
2728
$ms-icon-caret-svg-path: "M7.41,8.58L12,13.17L16.59,8.58L18,10L12,16L6,10L7.41,8.58Z" !default;
2829
$ms-icon-close-svg-path: "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" !default;

packages/multiple-select-vanilla/src/styles/multiple-select.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@
107107
align-items: center;
108108
cursor: pointer;
109109
width: 100%;
110-
height: 26px;
111110
overflow: hidden;
111+
height: var(--ms-choice-height, v.$ms-choice-height);
112112
padding: var(--ms-choice-padding, v.$ms-choice-padding);
113113
background-color: var(--ms-choice-bgcolor, v.$ms-choice-bgcolor);
114114
border: var(--ms-choice-border, v.$ms-choice-border);

0 commit comments

Comments
 (0)