Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Reactivity issue of FullCalendar in Drawer Component

Hello

I am working in a Vue 3 project that uses 8.1.6 Metronics version.

I need to display a FullCalendar Component in a "kt-drawer" Component but there is a reactivity issue and it seems that FullCalendar CSS (or maybe FullCalendar options ?) are not reactive so FullCalendar displays in this way when I click on "Dates" button :

https://a-p-c-t.fr/to-meet/fullCalendar-reactivity-issue.PNG

But if I did a code modification or I just display web browser inspector, FullCalendars is displayed correctly :

https://a-p-c-t.fr/to-meet/fullCalendar-ok.PNG

Kindly, could you check mon code et tell me how can I make reactive FullCalendar's Component ?

This is FullCalendar's Component code :

-------------------------------------------------------------------------------------

This is the "kt_drawer" component code :

--------------------------------------------------------------------------------

Thank you in advance.

Tania

Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (9)


Hi Tania,

Sorry for the late reply.

Your issue doesn't seem to be related to our drawer component.
Do you have the same problem when using a full calendar on vue-router page?

In your component, you have a custom Pania store and classes I assume that you are doing some asynchronous data fetch in there. I recommend testing the calendar with static data initially. Once the calendar functions with static data, you can then replace it with data from your server.

Explore examples of calendar usage in the official docs:


Regards,
Lauris Stepanovs,
Keenthemes Support Team



Hello Lauris

Thanks for reply

Well I added static data to Calendar (the static data of original calendar of Metronic theme) and I also included Calendar's component in same button's page... it is displayed correctly but, it is not the case of same Calendar's component on the "kt-drawer" Component.

Please check this image :


Maybe issue comes from Calendar's options service file ?

Kindly, could you check it ? :


import { reactive, ref } from "vue";
import moment from "moment";
import "moment/dist/locale/fr";
import frLocale from "@fullcalendar/core/locales/fr";
import "@fullcalendar/core/vdom";
import dayGridPlugin from "@fullcalendar/daygrid";
import timeGridPlugin from "@fullcalendar/timegrid";
import listPlugin from "@fullcalendar/list";
import interactionPlugin from "@fullcalendar/interaction";
import { todayDate, TODAY } from "@/app/pollCreation/allFakeData/eventsCal";
import type { Slot } from "@/services/interfaces/pollInterfaces/poll.interfaces";
import { elementEmitter } from "@/services/composables/eventEmitter"
import events from '../../../../../core/data/events';


export default class service {
allEventsSlots = ref<Slot[]>([]);
calendarEvents = reactive<any>([]);

getNewEvent = (e) => {
this.allEventsSlots.value.push(e);
};

getUpdateEvent = (x) => {
const response = this.allEventsSlots.value.findIndex((e) => e.idEvent === x.idEvent);
this.allEventsSlots.value.splice(response, 1, x); // splice : remplacer (il sert à update and delete) --> on récupre l'index, on splice un élément et on le remplace par x
elementEmitter.emitUpdate(this.allEventsSlots.value);
};

deleteEvent = reactive((a) => {
this.allEventsSlots.value.splice(
this.allEventsSlots.value.findIndex((e) => e.idEvent === a),
1
); // on recupere l'index et on splice 1 élément
this.calendarOptions.eventRemove;
elementEmitter.emitUpdate(this.allEventsSlots.value);
});

calendarOptions = reactive({
plugins: [dayGridPlugin, timeGridPlugin, listPlugin, interactionPlugin],
headerToolbar: {
left: "prev,next today",
center: "",
// right: "dayGridMonth,timeGridWeek,timeGridDay"
right: "title",
},
views: {
// dayGridMonth: { buttonText: "Mois" },
timeGridWeek: { buttonText: "Semaine" },
// timeGridDay: { buttonText: "Jours" },
},
initialView: "timeGridWeek",
locales: frLocale,
locale: "fr",
initialDate: TODAY,
firstDay: todayDate,
navLinks: true, // on peut cliquer sur les noms de jour/semaine pour naviguer dans les vues
selectable: true,
selectMirror: true,
events: events,
editable: true,
dayMaxEvents: true, // autoriser le lien "plus" lorsque trop d'événements
height:500,

selectAllow: (selectInfo) => {
// désactiver addEvent avant aujourd'hui
const beforeToday = todayDate.diff(selectInfo.start);
const noEventsBeforeToday = beforeToday <= 0;
return noEventsBeforeToday;
},

select: (calendarData) => {
const cal = calendarData.view.calendar;
cal.unselect();
cal.addEvent({
start: calendarData.start,
end: calendarData.end,
allDay: calendarData.allDay,
});
},

eventClick: (e) => {
const idEvent = e.event._instance.defId;
this.deleteEvent(idEvent);

e.event.remove();
},

eventAdd: (e) => {
this.calendarEvents.push(e)
const idEvent = e.event._instance.defId;
const start = moment(e.event.start).locale('fr').format("LLLL");
const end = moment(e.event.end).locale('fr').format("LLLL");

const newEvent = { idEvent, start, end };
this.getNewEvent(newEvent);

elementEmitter.emitUpdate(this.allEventsSlots.value);
},

eventChange: (e) => {
const idEvent = e.event._instance.defId;
const start = moment(e.event.start).locale('fr').format("LLLL");
const end = moment(e.event.end).locale('fr').format("LLLL");

const updateEvent = { idEvent, start, end };

this.getUpdateEvent(updateEvent);
},

eventRemove: (e) => {},
});

isCalendarOptions = () => {
return this.calendarOptions;
};
isallEventsSlots = () => {
return this.allEventsSlots
}
}


Thanks in advance for your help.

Tania



Hi Tania,

If the calendar functions correctly with static data, the issue is likely related to the structure of the response from your server. Please ensure that the object received from your servers matches the static object you pass into the calendar component.

Regards,
Lauris Stepanovs,
Keenthemes Support Team



Hello Lauris

I apologize, maybe I didn't explain myself correctly.

The issue is that Calendar on "kt-drawer" Component doesn't work with static data either.

On this image both Calendars are the same Calendar's Component

Kindly, check this video

Thank you in advace for your help

Tania



Hi Tania,

Thank you for specifying this.

Are you using the same component on the page and in drawer?

Check if there are any errors in your console.

Regards,
Lauris Stepanovs,
Keenthemes Support Team



Lauris

Yes, I using the same component on the page and in drawer but just to show you the issue. In any case, the issue continues to appear in the drawer, removing the Calendar from the page.

I toke a look to browser's warnings (chrome and firefox)... there are not errors but a lot of warnings. I found two warnings regarding Calendar. Check this image

Here is the video of the console warnings

Thanks for your help.

Tania



Hi Tania,

Sorry for the delay in reply.

We've successfully reproduced this issue - there seems to be an issue with the full calendar render when used in our drawer.

While we investigate this further, as a temporary solution, you can force a rerender of the component by dispatching a resize event.


onMounted(() => {
nextTick(function () {
window.dispatchEvent(new Event("resize"));
});
});


Regards,
Lauris Stepanovs,
Keenthemes Support Team



Hello Lauris

Happy new year and thank you very much !
Calendar used in drawer works correctly.

Regards,
Tania



Hi Tania,

Happy New Year! I'm glad to hear it worked for you. If you have more questions on this topic or anything else, feel free to ask.

Regards,
Lauris Stepanovs,
Keenthemes Support Team


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(