From a8264e7a6404d024eab9be042e5f2ede4acedef9 Mon Sep 17 00:00:00 2001
From: Alexander Purr <purr@ub.uni-leipzig.de>
Date: Fri, 13 May 2022 14:00:35 +0200
Subject: [PATCH] refs #21825 [finc] rvk notation: correct nested rvk lists

* move brake condition for nested list - prevents from empty last item
* display list indicator only at first element - prevents from doubled occurrence in nested lists
* span to div - lists can not be subelements of spans
* dropdown and nested list marked as role=tree
* improved foreach-loop

co-authored by: Claas Kazzer <kazzer@uni-leipzig.de>
* fixes tree and treeitem roles
---
 themes/finc/scss/compiled.scss                |  4 +-
 .../finc/templates/Helpers/nestedList.phtml   | 14 +++---
 .../DefaultRecord/data-rvkNotation.phtml      | 43 +++++++++----------
 3 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/themes/finc/scss/compiled.scss b/themes/finc/scss/compiled.scss
index 9f5f878014f..62190274ddd 100644
--- a/themes/finc/scss/compiled.scss
+++ b/themes/finc/scss/compiled.scss
@@ -819,7 +819,7 @@ a.toggle {
   }
 }
 
-span.notation ul {
+.notation ul {
   padding-inline-start: 1.5em;
 
   @media (max-width: $screen-md-min) {
@@ -830,7 +830,7 @@ span.notation ul {
     list-style-type: none;
   }
 
-  li::before {
+  li:nth-of-type(1)::before {
     content: $fa-var-level-down;
     font-family: 'FontAwesome', sans-serif;
     margin-right: .5em;
diff --git a/themes/finc/templates/Helpers/nestedList.phtml b/themes/finc/templates/Helpers/nestedList.phtml
index acba95440d9..d52cc8d0309 100644
--- a/themes/finc/templates/Helpers/nestedList.phtml
+++ b/themes/finc/templates/Helpers/nestedList.phtml
@@ -1,8 +1,10 @@
-<?php //Base case: an empty array produces no list ?>
-<?php if (!empty($array)): ?>
-    <ul>
-        <li><?=array_shift($array)?></li>
+<ul role="tree">
+    <li role="listitem"><?=array_shift($array)?></li>
+    <?php if (!empty($array)): ?>
+      <li role="listitem">
         <?php //Recursive Step: make a list with child lists ?>
         <?= $this->render('Helpers/nestedList.phtml', ['array' => $array])?>
-    </ul>
-<?php endif; ?>
\ No newline at end of file
+      </li>
+    <?php endif; ?>
+</ul>
+
diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/data-rvkNotation.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/data-rvkNotation.phtml
index 59cc4551a62..d558ee2482d 100644
--- a/themes/finc/templates/RecordDriver/DefaultRecord/data-rvkNotation.phtml
+++ b/themes/finc/templates/RecordDriver/DefaultRecord/data-rvkNotation.phtml
@@ -1,26 +1,25 @@
 <!-- finc: RecordDriver - DefaultRecord - data-rvkNotation -->
 <?php /* partial copied from themes/finc/templates/RecordTab/topics.phtml */ ?>
-<?php $i = 0; foreach ($data as $item): ?>
-    <?=($i>0?"<br />":"") //no linebreak after last item ?>
-
-    <span>
-        <a href="<?=$this->record($this->driver)->getLink('rvk', $item['rvk'])?>">
-          <?=$item['rvk']?>
-        </a>
-    </span>
-
-    <?php if(isset($item['name'])): ?>
-      <a class="toggle" role="button" data-toggle="collapse" href="#collapse_rvk_<?=$i?>" aria-expanded="false" aria-controls="collapse_rvk_<?=$i?>">
-          <?=$item['name']?>
-      </a>
-    <?php endif; ?>
-
-    <?php if(isset($item['level']) && is_array($item['level'])): ?>
-      <span id="collapse_rvk_<?=$i?>" class="collapse notation">
-        <?= $this->render('Helpers/nestedList.phtml', ['array' => $item['level']]); ?>
-      </span>
-    <?php endif; ?>
-
-    <?php $i++; ?>
+<?php foreach ($data as $i => $item): ?>
+    <div>
+        <span>
+            <a href="<?=$this->record($this->driver)->getLink('rvk', $item['rvk'])?>">
+              <?=$item['rvk']?>
+            </a>
+        </span>
+    
+        <?php if(isset($item['name'])): ?>
+          <a class="toggle" role="button" data-toggle="collapse" href="#collapse_rvk_<?=$i?>" aria-expanded="false" aria-controls="collapse_rvk_<?=$i?>">
+              <?=$item['name']?>
+          </a>
+        <?php endif; ?>
+    
+        <?php if(isset($item['level']) && is_array($item['level'])): ?>
+          <div id="collapse_rvk_<?=$i?>" class="collapse notation">
+            <?= $this->render('Helpers/nestedList.phtml', ['array' => $item['level']]); ?>
+          </div>
+        <?php endif; ?>
+      
+    </div>
 <?php endforeach; ?>
 <!-- finc: RecordDriver - DefaultRecord - data-rvkNotation - END -->
\ No newline at end of file
-- 
GitLab