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

"MAGENE Sem Joel \(@Jomagene\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69eff0736b14_3818f100-11f@gitlab-sidekiq-low-urgency-cpu-bound-v2-5b47d4b6d4-sm47h.mail>

MAGENE Sem Joel pushed to branch 30.x at Tiki Wiki CMS Groupware / Tiki


Commits:
a50e63b3 by MAGENE Sem Joel at 2026-04-27T23:18:07+00:00
[BP][FIX][UX] Calendar: preserve active view when date picker changes date
---
* [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

(cherry picked from commit e3acb65b35471e68d42cfcd9a96094b7e1a67c9c)

See merge request tikiwiki/tiki!10090

- - - - -


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/a50e63b3dd0d6c282a3626febc734da341421ee1

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/a50e63b3dd0d6c282a3626febc734da341421ee1
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.