From b64f21167ceab97a4e433aeabae475687575a470 Mon Sep 17 00:00:00 2001
From: comete-upn <logicielslibres@liste.parisnanterre.fr>
Date: Mon, 7 Feb 2022 09:10:00 +0100
Subject: [PATCH] =?UTF-8?q?Ne=20permuter=20les=20menus=20de=20section=20qu?=
 =?UTF-8?q?e=20s=E2=80=99ils=20existent.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 format.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/format.js b/format.js
index ab865fc..0eeeafa 100644
--- a/format.js
+++ b/format.js
@@ -42,7 +42,10 @@ M.course.format.swap_sections = function(Y, node1, node2) {
         SECTIONADDMENUS: 'section_add_menus'
     };
     var sectionlist = Y.Node.all('.' + CSS.COURSECONTENT + ' ' + M.course.format.get_section_selector(Y));
-    sectionlist.item(node1).one('.' + CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.' + CSS.SECTIONADDMENUS));
+    // Swap the non-ajax menus, noting these are not always present (depends on theme and user prefs).
+    if (sectionlist.item(node1).one('.' + CSS.SECTIONADDMENUS)) {
+        sectionlist.item(node1).one('.' + CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.' + CSS.SECTIONADDMENUS));
+    }
 };
 
 M.course.format.process_sections = function(Y, sectionlist, response, sectionfrom, sectionto) {
-- 
GitLab