Skip to content

Commit 6a9754c

Browse files
authored
Merge pull request #1094 from chocolateimage/appcontext-slot-fix
fix: App Context missing in slots
2 parents 03226c6 + a992a6c commit 6a9754c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/VueDatePicker/VueDatePicker.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
watch,
8484
Teleport as TeleportCmp,
8585
nextTick,
86+
getCurrentInstance,
8687
} from 'vue';
8788
8889
import DatepickerInput from '@/components/DatepickerInput.vue';
@@ -178,6 +179,8 @@
178179
const { menuTransition, showTransition } = useTransitions(defaultedTransitions);
179180
const { isMobile } = useResponsive(defaultedConfig);
180181
182+
const currentInstance = getCurrentInstance();
183+
181184
onMounted(() => {
182185
parseExternalModelValue(props.modelValue);
183186
nextTick().then(() => {
@@ -320,7 +323,7 @@
320323
321324
const openMenu = () => {
322325
if (!props.disabled && !props.readonly) {
323-
shadowRender(DatepickerMenu, props);
326+
shadowRender(currentInstance, DatepickerMenu, props);
324327
setMenuPosition(false);
325328
isOpen.value = true;
326329

src/VueDatePicker/composables/position.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Component, ComputedRef, Ref, Slots } from 'vue';
1+
import type { Component, ComponentInternalInstance, ComputedRef, Ref, Slots } from 'vue';
22
import { h, ref, render, toRef, watch } from 'vue';
33
import {
44
type DatepickerInputRef,
@@ -255,7 +255,7 @@ export const usePosition = ({
255255
};
256256

257257
// Renders invisible menu on open to determine the menu dimensions
258-
const shadowRender = (DPMenu: Component, props: AllPropsType) => {
258+
const shadowRender = (instance: ComponentInternalInstance | null, DPMenu: Component, props: AllPropsType) => {
259259
const container = document.createElement('div');
260260
const input = unrefElement(inputRef as MaybeElementRef)?.getBoundingClientRect();
261261
container.setAttribute('id', 'dp--temp-container');
@@ -278,6 +278,9 @@ export const usePosition = ({
278278
},
279279
Object.fromEntries(mappedSlots.map((slot) => [slot, slots[slot]])),
280280
);
281+
if (instance != null) {
282+
el.appContext = instance.appContext;
283+
}
281284

282285
render(el, container);
283286
menuRect.value = el.el?.getBoundingClientRect();

0 commit comments

Comments
 (0)