From 6c9936f389e58de08a7a0a452801a41b6766e33e Mon Sep 17 00:00:00 2001
From: Liliana Sanfilippo <lsanfilippo@techfak.uni-bielefeld.de>
Date: Sat, 23 Nov 2024 16:44:57 +0100
Subject: [PATCH] lik fix

---
 src/components/Link.tsx       | 11 +++++++----
 src/components/interfaces.tsx |  3 ++-
 src/utils/useNavigation.ts    | 19 +++++++++++--------
 3 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/src/components/Link.tsx b/src/components/Link.tsx
index cec64603..792913fb 100644
--- a/src/components/Link.tsx
+++ b/src/components/Link.tsx
@@ -10,14 +10,17 @@ export function TabScrollLink({tab, scrollId, num}:{tab: string, scrollId: strin
 
 
 
-// 2^4 = 16 possible combinations
-
-export function OurLink({path, scrollToId, tabId, subTabId, collapseId, text}:Ourlink){
+// 2^4 = 16 possible combinations + 1 special case
+export function OurLink({path, scrollToId, tabId, subTabId, collapseId, text, tabincolId}:Ourlink){
     const {goToPlace} = useNavigation(); 
     // 1. [1-1-1-1] go to page and open tab and open collapsible and open subtab in collapsible and scroll to something
-    if(tabId && subTabId && scrollToId && collapseId) {
+    if(tabId && subTabId && scrollToId && collapseId && !tabincolId) {
         return(<a onClick={() => goToPlace({path: path, tabId: tabId, subTabId: subTabId, scrollToId:scrollToId, collapseId:collapseId})}>{text}</a>)    
     } 
+    // special case if tab in collapsible shall be opened
+    if(tabId && subTabId && scrollToId && collapseId && tabincolId) {
+        return(<a onClick={() => goToPlace({path: path, tabId: tabId, subTabId: subTabId, scrollToId:scrollToId, collapseId:collapseId, tabincolId:tabincolId})}>{text}</a>)    
+    } 
     // 2. [1-1-1-0] go to page and open tab and open subtab and scroll to something
     else if (tabId && subTabId && scrollToId && !collapseId){
         return(<a onClick={() => goToPlace({path: path, tabId: tabId, subTabId: subTabId, scrollToId:scrollToId})}>{text}</a>)
diff --git a/src/components/interfaces.tsx b/src/components/interfaces.tsx
index 53b9ceb7..5345ce76 100644
--- a/src/components/interfaces.tsx
+++ b/src/components/interfaces.tsx
@@ -4,5 +4,6 @@ export interface Ourlink{
     scrollToId?: string,
     tabId?: string,
     subTabId?: string,
-    collapseId?: string
+    collapseId?: string,
+    tabincolId?: string
 }
\ No newline at end of file
diff --git a/src/utils/useNavigation.ts b/src/utils/useNavigation.ts
index 16facf74..067dcb07 100644
--- a/src/utils/useNavigation.ts
+++ b/src/utils/useNavigation.ts
@@ -52,26 +52,29 @@ export const useNavigation = () => {
 
   
 
-    const goToPlace = ({ path, scrollToId,tabId, subTabId, collapseId}: { path: string, scrollToId?: string, tabId?: string, subTabId?: string, collapseId?: string}) => {
+    const goToPlace = ({ path, scrollToId,tabId, subTabId, collapseId, tabincolId}: { path: string, scrollToId?: string, tabId?: string, subTabId?: string, collapseId?: string, tabincolId?: string}) => {
         let url = `${path}`;
         if (tabId) {
             url += `?tab=${tabId}`;
-            if (collapseId) {
-                url += `&collapseId=${collapseId}`;
-            }
             if (subTabId) {
                 url += `&subTab=${subTabId}`;
             }
         }
         if (collapseId && !tabId) {
             url += `?collapseId=${collapseId}`;
-            if (subTabId) {
-                url += `&subTab=${subTabId}`;
+            if (tabincolId) {
+                url += `&colTab=${tabincolId}`;  
+            }
+        }
+        if (collapseId) {
+            url += `&collapseId=${collapseId}`;
+            if (tabincolId) {
+                url += `&colTab=${tabincolId}`;  
             }
         }
-        if (scrollToId && !tabId) {
+        if (scrollToId && !tabId || scrollToId && !collapseId) {
             url += `?scrollTo=${scrollToId}`;
-        } else if (scrollToId && tabId) {
+        } else if (scrollToId && tabId || scrollToId && collapseId) {
             url += `&scrollTo=${scrollToId}`;
         } 
         navigate(url);
-- 
GitLab