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

Commit de9c344

Browse files
committed
fix: Prevent position recalculate when auto-position is set to false (fixes #97)
1 parent 3132016 commit de9c344

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/Vue3DatePicker/Vue3DatePicker.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@
318318
const { openOnTop, menuPosition, setMenuPosition, recalculatePosition } = usePosition(
319319
props.position,
320320
props.altPosition,
321+
props.autoPosition,
321322
dpMenuRef,
322323
inputRef,
323324
emit,

src/Vue3DatePicker/components/composition/position.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type ComponentRef = Ref<HTMLElement | null>;
1717
export const usePosition = (
1818
openPosition: OpenPosition,
1919
altPosition: AltPosition,
20+
autoPosition: boolean,
2021
menuRef: ComponentRef,
2122
inputRef: ComponentRef,
2223
emit: VueEmit,
@@ -76,7 +77,7 @@ export const usePosition = (
7677
position.transform = `translateX(-50%)`;
7778
}
7879
menuPosition.value = position;
79-
if (recalculate) {
80+
if (recalculate && autoPosition) {
8081
recalculatePosition();
8182
}
8283
}
@@ -88,7 +89,7 @@ export const usePosition = (
8889
*/
8990
const recalculatePosition = (): void => {
9091
const el = unrefElement(inputRef);
91-
if (el) {
92+
if (el && autoPosition) {
9293
const { height: inputHeight, top } = el.getBoundingClientRect();
9394
const { top: offset } = altPosition ? getOffsetAlt(el) : getOffset(el);
9495
const fullHeight = window.innerHeight;

0 commit comments

Comments
 (0)