[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX][UX] Calendar: preserve active view when date picker changes date

"Adrien Mbuya Maloba \(@adrienmaloba\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69efccfaf068e_3818eee47218c@gitlab-sidekiq-low-urgency-cpu-bound-v2-549b554c7c-fftvd.mail>

Adrien Mbuya Maloba pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
e3acb65b by MAGENE Sem Joel at 2026-04-27T23:46:36+03:00
[FIX][UX] Calendar: preserve active view when date picker changes date
---
* [FIX][UX] Calendar: preserve active view when date picker changes date

See merge request tikiwiki/tiki!10081

- - - - -


1 changed file:

- src/js/jquery-tiki/tiki-calendar.js


Changes:

=====================================
src/js/jquery-tiki/tiki-calendar.js
=====================================
@@ -129,8 +129,15 @@ $.fn.setupEventCalendar = function (
             view: eventCalendarParams.initialView,
             date: eventCalendarParams.initialDate,
             viewDidMount: function (data) {
+                // Preserve selected view across date-picker re-renders (callback can expose `data.type` or `data.view.type`).
+                const mountedViewType = data?.type ?? data?.view?.type;
+                // Use `data.type` for existing toolbar condition checks
+                const legacyToolbarViewType = data?.type;
+                if (mountedViewType) {
+                    eventCalendarParams.initialView = mountedViewType;
+                }
                 $(calendarEl).tikiModal();
-                if (data.type == "dayGridMonth" || data.type == "listMonth") {
+                if (legacyToolbarViewType == "dayGridMonth" || legacyToolbarViewType == "listMonth") {
                     calendarContainer[0].setOption("duration", { months: 1 });
                     if (!document.getElementById("quarter")) {
                         const ecStart = document.querySelector(".ec-start");
@@ -188,20 +195,20 @@ $.fn.setupEventCalendar = function (
                         document.getElementById("quarter").remove();
                         document.getElementById("semester").remove();
                     }
-                    if (data.type == "timeGridWeek" || data.type == "listWeek") {
+                    if (legacyToolbarViewType == "timeGridWeek" || legacyToolbarViewType == "listWeek") {
                         calendarContainer[0].setOption("duration", { days: 7 });
                         calendarContainer[0].setOption("dayCellFormat", function (dayCell) {
                             return moment(dayCell).format("D");
                         });
                     }
-                    if (data.type == "timeGridDay" || data.type == "listDay") {
+                    if (legacyToolbarViewType == "timeGridDay" || legacyToolbarViewType == "listDay") {
                         calendarContainer[0].setOption("duration", { days: 1 });
                         calendarContainer[0].setOption("dayCellFormat", function (dayCell) {
                             return moment(dayCell).format("D");
                         });
                     }
 
-                    if (data.type == "listYear") {
+                    if (legacyToolbarViewType == "listYear") {
                         calendarContainer[0].setOption("duration", { months: 12 });
                         calendarContainer[0].setOption("dayCellFormat", function (dayCell) {
                             return moment(dayCell).format("D");
@@ -504,10 +511,14 @@ $.fn.defineParameterOfMultipleCalendar = function (
     $(divClassContainer)
         .eq(takeLength - 1)
         .append(newNode);
-    paramOfModuleCalendar["initialDate"] = $("#date-calendar" + takeLength).val();
+    paramOfModuleCalendar["initialDate"] = dateOfChangeCalendar.val();
 
     displayCalendarAndPrintButton(takeLength);
     dateOfChangeCalendar.on("change", function () {
+        const currentView = calendarContainer[0]?.getView?.();
+        if (currentView?.type) {
+            paramOfModuleCalendar["initialView"] = currentView.type;
+        }
         paramOfModuleCalendar["initialDate"] = dateOfChangeCalendar.val();
         let takeIndex = dateOfChangeCalendar.attr("id").split("-")[2];
         newNode.empty();



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/e3acb65b35471e68d42cfcd9a96094b7e1a67c9c

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/e3acb65b35471e68d42cfcd9a96094b7e1a67c9c
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.