Skip to content

Commit

Permalink
Merge pull request #306 from City-of-Helsinki/UHF-10892
Browse files Browse the repository at this point in the history
UHF-10892 Gin sidebar
  • Loading branch information
khalima authored Oct 25, 2024
2 parents f3284d0 + b5fa1b5 commit 9114845
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,12 @@
"drupal/gin": ">3.0.0-rc11",
"drupal/helfi_platform_config": "<4.3",
"drupal/helfi_api_base": "<2.7.6"
},
"extra": {
"patches": {
"drupal/gin": {
"[#UHF-10892] Gin sidebar nextsibling issue. (https://www.drupal.org/i/3460390)": "https://raw.githubusercontent.com/City-of-Helsinki/drupal-hdbt-admin/d3e6cb08315b8df38696489d2c8f406a67f224b8/patches/gin-3460390-sidebar-nextsibling-innerhtml-rc11.patch"
}
}
}
}
57 changes: 57 additions & 0 deletions patches/gin-3460390-sidebar-nextsibling-innerhtml-rc11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
diff --git a/dist/js/sidebar.js b/dist/js/sidebar.js
index 979bdcb..6c32188 100644
--- a/dist/js/sidebar.js
+++ b/dist/js/sidebar.js
@@ -30,9 +30,10 @@
const chooseStorage = window.innerWidth < 1024 ? "Drupal.gin.sidebarExpanded.mobile" : storageDesktop, hideLabel = Drupal.t("Hide sidebar panel"), sidebarTrigger = document.querySelector(".meta-sidebar__trigger");
var _Drupal$ginCoreNaviga;
if (sidebarTrigger.querySelector("span").innerHTML = hideLabel, sidebarTrigger.setAttribute("title", hideLabel),
- sidebarTrigger.nextSibling.innerHTML = hideLabel, sidebarTrigger.setAttribute("aria-expanded", "true"),
- sidebarTrigger.classList.add("is-active"), document.body.setAttribute("data-meta-sidebar", "open"),
- localStorage.setItem(chooseStorage, "true"), window.innerWidth < 1280) if (null === (_Drupal$ginCoreNaviga = Drupal.ginCoreNavigation) || void 0 === _Drupal$ginCoreNaviga || _Drupal$ginCoreNaviga.collapseToolbar(),
+ sidebarTrigger.nextSibling && (sidebarTrigger.nextSibling.innerHTML = hideLabel),
+ sidebarTrigger.setAttribute("aria-expanded", "true"), sidebarTrigger.classList.add("is-active"),
+ document.body.setAttribute("data-meta-sidebar", "open"), localStorage.setItem(chooseStorage, "true"),
+ window.innerWidth < 1280) if (null === (_Drupal$ginCoreNaviga = Drupal.ginCoreNavigation) || void 0 === _Drupal$ginCoreNaviga || _Drupal$ginCoreNaviga.collapseToolbar(),
"vertical" === toolbarVariant) Drupal.ginToolbar.collapseToolbar(); else if ("new" === toolbarVariant) {
var _Drupal$behaviors$gin;
null === (_Drupal$behaviors$gin = Drupal.behaviors.ginNavigation) || void 0 === _Drupal$behaviors$gin || _Drupal$behaviors$gin.collapseSidebar();
@@ -41,9 +42,9 @@
collapseSidebar: () => {
const chooseStorage = window.innerWidth < 1024 ? "Drupal.gin.sidebarExpanded.mobile" : storageDesktop, showLabel = Drupal.t("Show sidebar panel"), sidebarTrigger = document.querySelector(".meta-sidebar__trigger");
sidebarTrigger.querySelector("span").innerHTML = showLabel, sidebarTrigger.setAttribute("title", showLabel),
- sidebarTrigger.nextSibling.innerHTML = showLabel, sidebarTrigger.setAttribute("aria-expanded", "false"),
- sidebarTrigger.classList.remove("is-active"), document.body.setAttribute("data-meta-sidebar", "closed"),
- localStorage.setItem(chooseStorage, "false");
+ sidebarTrigger.nextSibling && (sidebarTrigger.nextSibling.innerHTML = showLabel),
+ sidebarTrigger.setAttribute("aria-expanded", "false"), sidebarTrigger.classList.remove("is-active"),
+ document.body.setAttribute("data-meta-sidebar", "closed"), localStorage.setItem(chooseStorage, "false");
},
handleResize: function() {
let windowSize = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : window;
diff --git a/js/sidebar.js b/js/sidebar.js
index b8b97c5..a6155c6 100644
--- a/js/sidebar.js
+++ b/js/sidebar.js
@@ -83,7 +83,9 @@

sidebarTrigger.querySelector('span').innerHTML = hideLabel;
sidebarTrigger.setAttribute('title', hideLabel);
- sidebarTrigger.nextSibling.innerHTML = hideLabel;
+ if (sidebarTrigger.nextSibling) {
+ sidebarTrigger.nextSibling.innerHTML = hideLabel;
+ }
sidebarTrigger.setAttribute('aria-expanded', 'true');
sidebarTrigger.classList.add('is-active');

@@ -111,7 +113,9 @@

sidebarTrigger.querySelector('span').innerHTML = showLabel;
sidebarTrigger.setAttribute('title', showLabel);
- sidebarTrigger.nextSibling.innerHTML = showLabel;
+ if (sidebarTrigger.nextSibling) {
+ sidebarTrigger.nextSibling.innerHTML = showLabel;
+ }
sidebarTrigger.setAttribute('aria-expanded', 'false');
sidebarTrigger.classList.remove('is-active');

0 comments on commit 9114845

Please sign in to comment.