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

Commit 000a177

Browse files
committed
fix: Proper positioning of inline date picker
1 parent 0c49656 commit 000a177

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/Vue3DatePicker/Vue3DatePicker.vue

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="dp__main" :class="theme">
2+
<div :class="wrapperClass">
33
<DatepickerInput
44
:internal-value="internalValue"
55
:placeholder="placeholder"
@@ -24,7 +24,7 @@
2424
<slot name="clear-icon"></slot>
2525
</template>
2626
</DatepickerInput>
27-
<teleport to="body">
27+
<teleport to="body" :disabled="inline">
2828
<DatepickerMenu
2929
:class="theme"
3030
:uid="uid"
@@ -69,7 +69,7 @@
6969

7070
<script lang="ts">
7171
import { computed, defineComponent, onMounted, onUnmounted, PropType, ref, toRef, watch } from 'vue';
72-
import { FormatOptions, IDateFilter, ITimeRange, OpenPosition, RDatepickerProps } from './interfaces';
72+
import { FormatOptions, IDateFilter, ITimeRange, OpenPosition, RDatepickerProps, DynamicClass } from './interfaces';
7373
import DatepickerInput from './components/DatepickerInput.vue';
7474
import DatepickerMenu from './components/DatepickerMenu.vue';
7575
import { formatRangeDate, formatSingleDate } from './utils/util';
@@ -161,9 +161,7 @@
161161
}
162162
window.addEventListener('resize', setMenuPosition);
163163
if (props.inline) {
164-
// // @ts-ignore
165-
// menuPosition.value = { position: 'relative' };
166-
openMenu();
164+
isOpen.value = true;
167165
}
168166
});
169167
@@ -174,6 +172,15 @@
174172
window.removeEventListener('resize', setMenuPosition);
175173
});
176174
175+
const wrapperClass = computed(
176+
(): DynamicClass => ({
177+
dp__main: true,
178+
dp__theme_dark: props.dark,
179+
dp__theme_light: !props.dark,
180+
dp__flex_display: props.inline,
181+
}),
182+
);
183+
177184
const theme = computed(() => (props.dark ? 'dp__theme_dark' : 'dp__theme_light'));
178185
179186
const isSingle = computed((): boolean => !props.range);
@@ -342,6 +349,7 @@
342349
closeMenu,
343350
selectDate,
344351
theme,
352+
wrapperClass,
345353
recalculatePosition,
346354
};
347355
},

src/Vue3DatePicker/components/DatepickerMenu.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
const dpMenuClass = computed(
106106
(): DynamicClass => ({
107107
[props.menuClassName]: !!props.menuClassName,
108+
dp__flex_display: props.inline,
108109
}),
109110
);
110111

src/Vue3DatePicker/style/main.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,8 @@
8383
width: auto;
8484
}
8585
}
86+
87+
.dp__flex_display {
88+
display: flex;
89+
position: relative;
90+
}

0 commit comments

Comments
 (0)