Skip to content
This repository was archived by the owner on Apr 17, 2022. It is now read-only.

Commit b062b6c

Browse files
committed
fix: Menu positioning when not enough space on top and bottom
1 parent 3a5bd22 commit b062b6c

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/Vue3DatePicker/Vue3DatePicker.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -327,18 +327,28 @@
327327
if (el) {
328328
const { height: inputHeight, top } = el.getBoundingClientRect();
329329
const fullHeight = window.innerHeight;
330-
const freeSpace = fullHeight - top - inputHeight;
330+
const freeSpaceBottom = fullHeight - top - inputHeight;
331+
331332
const menuEl = document.getElementById(`dp__menu_${props.uid}`);
332333
333334
if (menuEl) {
334335
const { height } = menuEl.getBoundingClientRect();
335336
const menuHeight = height + inputHeight;
336-
if (menuHeight > freeSpace) {
337-
menuPosition.value.top = `${el.offsetTop - height - 12}px`;
338-
openOnTop.value = true;
337+
if (menuHeight > top && menuHeight > freeSpaceBottom) {
338+
if (top > freeSpaceBottom) {
339+
openOnTop.value = true;
340+
} else {
341+
setMenuPosition(false);
342+
openOnTop.value = false;
343+
}
339344
} else {
340-
setMenuPosition(false);
341-
openOnTop.value = false;
345+
if (menuHeight > freeSpaceBottom) {
346+
menuPosition.value.top = `${el.offsetTop - height - 12}px`;
347+
openOnTop.value = true;
348+
} else {
349+
setMenuPosition(false);
350+
openOnTop.value = false;
351+
}
342352
}
343353
}
344354
}

0 commit comments

Comments
 (0)