From 772b7aa80a1d01889c129bbbe710bca9521a3633 Mon Sep 17 00:00:00 2001 From: Miguel Ribeiro Date: Fri, 5 Jul 2024 21:36:05 +0200 Subject: [PATCH] fix: dashboard scrolling to top when opening a subscription --- includes/version.php | 2 +- index.php | 286 +++++++++++++++++++++---------------------- scripts/dashboard.js | 6 + styles/styles.css | 6 + 4 files changed, 155 insertions(+), 145 deletions(-) diff --git a/includes/version.php b/includes/version.php index e360ce324..83de57a2f 100644 --- a/includes/version.php +++ b/includes/version.php @@ -1,3 +1,3 @@ \ No newline at end of file diff --git a/index.php b/index.php index 36004c81d..87168b481 100644 --- a/index.php +++ b/index.php @@ -222,183 +222,181 @@ } ?> + +
+
+

+ +
+
-
-
-

- -
- - -
- - - - -
- -
- - +
+ + + + +
+
- -
- - + + +
-
-
-
- -
- - -
-
-
- - -
-
-
+
+ + +
-
-
-
- - - + -
-
- - - +
+
+ + +
+
-
- - + + + - + +
+
+ + + foreach ($members as $member) { + ?> + + + +
+ -
- - -
+
+ + +
-
-
-
- - + +
+ +
+
+
+ + -
-
- - -
+ + + +
+
+ +
+
-
- -
+
+ +
-
- -
+
+ +
-
- - -
+
+ + +
-
- - - -
- -
+
+ + + +
+
diff --git a/scripts/dashboard.js b/scripts/dashboard.js index 4409301c2..c7b381e5c 100644 --- a/scripts/dashboard.js +++ b/scripts/dashboard.js @@ -1,4 +1,6 @@ let isSortOptionsOpen = false; +let scrollTopBeforeOpening = 0; +const shouldScroll = window.innerWidth <= 768; function toggleOpenSubscription(subId) { const subscriptionElement = document.querySelector('.subscription[data-id="' + subId + '"]'); @@ -105,6 +107,7 @@ function fillEditFormFields(subscription) { function openEditSubscription(event, id) { event.stopPropagation(); + scrollTopBeforeOpening = window.scrollY; const body = document.querySelector('body'); body.classList.add('no-scroll'); const url = `endpoints/subscription/get.php?id=${id}`; @@ -142,6 +145,9 @@ function closeAddSubscription() { modal.classList.remove("is-open"); const body = document.querySelector('body'); body.classList.remove('no-scroll'); + if (shouldScroll) { + window.scrollTo(0, scrollTopBeforeOpening); + } resetForm(); } diff --git a/styles/styles.css b/styles/styles.css index eb40b6376..ef6c14f4e 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -10,6 +10,12 @@ body.no-scroll { overflow-y: hidden; } +@media (max-width: 768px) { + body.no-scroll section.contain { + display: none; + } +} + a:hover > i { color: var(--hover-color); }