From ad972ece039a651f799c23ec7dc8ab8e8e06bd56 Mon Sep 17 00:00:00 2001
From: Viola Elsenhans <elsenhans@ub.uni-leipzig.de>
Date: Mon, 21 Aug 2023 09:54:58 +0200
Subject: [PATCH] refs #24358 [finc] distinguish origin of template for setting
 either aria-label or aria-describedby

---
 .../finc/templates/RecordDriver/DefaultRecord/toolbar.phtml  | 3 ++-
 themes/finc/templates/record/cart-buttons.phtml              | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/toolbar.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/toolbar.phtml
index fdb24dcec2e..c1585608ced 100644
--- a/themes/finc/templates/RecordDriver/DefaultRecord/toolbar.phtml
+++ b/themes/finc/templates/RecordDriver/DefaultRecord/toolbar.phtml
@@ -78,7 +78,8 @@
     <?php endif; ?>
     <?php /* finc adds bookbag feature */ ?>
     <li class="bookbag-menu">
-      <?=$this->render('record/cart-buttons.phtml', ['id' => $this->driver->getUniqueId(), 'source' => $this->driver->getSourceIdentifier()]); ?>
+      <?php /* finc adds callFromTemplate to distinguish if use of book bag is with or without checkbox for setting either aria-label or aria-describedby #24358 */ ?>
+      <?=$this->render('record/cart-buttons.phtml', ['id' => $this->driver->getUniqueId(), 'source' => $this->driver->getSourceIdentifier(), 'callFromTemplate' => 'toolbar' ]); ?>
     </li>
   </ul>
 </nav>
diff --git a/themes/finc/templates/record/cart-buttons.phtml b/themes/finc/templates/record/cart-buttons.phtml
index 46a57cf85e0..c9388056d58 100644
--- a/themes/finc/templates/record/cart-buttons.phtml
+++ b/themes/finc/templates/record/cart-buttons.phtml
@@ -5,10 +5,11 @@
     <?php /* finc changes span to div */ ?>
     <div class="btn-bookbag-toggle" data-cart-id="<?=$this->escapeHtmlAttr($this->id)?>" data-cart-source="<?=$this->escapeHtmlAttr($this->source)?>">
     <?php /* finc makes add-to/remove-from bookbag accessible for keyboard navigation - CK */ ?>
-    <a href="javascript:" class="cart-add hidden<?php if (!$cart->contains($cartId)): ?> correct<?php endif ?>" aria-describedby="<?=$cartId?>">
+    <?php /* finc uses callFromTemplate to distinguish if use of book bag is with or without checkbox for setting either aria-label or aria-describedby #24358 */ ?>
+    <a href="javascript:" class="cart-add hidden<?php if (!$cart->contains($cartId)): ?> correct<?php endif ?>" <?php if ($this->callFromTemplate === 'toolbar'): ?>aria-describedby="<?=$cartId?>"<?php else: ?>aria-describedby="<?=$cartId?>"<?php endif ?>>
       <span class="cart-link-label btn-type-add"><?=$this->transEsc('Add to Book Bag')?></span>
     </a>
-    <a href="javascript:" class="cart-remove hidden<?php if ($cart->contains($cartId)): ?> correct<?php endif ?>" aria-describedby="<?=$cartId?>">
+    <a href="javascript:" class="cart-remove hidden<?php if ($cart->contains($cartId)): ?> correct<?php endif ?>" <?php if ($this->callFromTemplate === 'toolbar'): ?>aria-describedby="<?=$cartId?>"<?php else: ?>aria-describedby="<?=$cartId?>"<?php endif ?>>
       <span class="cart-link-label btn-type-minus"><?=$this->transEsc('Remove from Book Bag')?></span>
     </a>
 
-- 
GitLab