ETT-1542: fix viewability table viewport a11y issue - #144
Conversation
| <a data-activated-role="true" href="{$handle_prefix}{$ld.handle}" referrerpolicy="unsafe-url"> | ||
| <i aria-hidden="true" class="fa-solid fa-unlock"></i> | ||
| <span class="text-decoration-underline">Limited (Access Permitted)</span> | ||
| {if (isset($ld.enumchron) and $ld.enumchron)}<span class="IndItem">{$ld.enumchron}</span>{/if} |
There was a problem hiding this comment.
This check treats the text "0" as if it were empty.
{if (isset($ld.enumchron) and $ld.enumchron)} will hide the value when $ld.enumchron is the string "0", because PHP and Smarty treat "0" as false in a boolean check. Before this PR, the value was always shown, even if it was "0".
If a volume or issue is ever labeled just "0", it will now disappear from the link instead of showing up.
Suggested fix: check for an empty string directly instead of relying on truthiness, for example:
{if isset($ld.enumchron) and $ld.enumchron !== ''}
This same check is repeated on other lines, so the fix should be made in all five places (or pulled out into one shared check before the if/elseif chain).
There was a problem hiding this comment.
@eumalin Thanks for the feedback! I googled a bit and found this {capture} function in smarty that holds template pieces as variables, so I used that to compute the enumchron template piece one time if it exists for that record and then insert where needed.
Edit to add: re-staged on dev-3
Most of this is reformatting the html, but I also removed unnecessary comments and whitespace.
While working on the css for this, I realized that the span that houses the enumchron data (
<span class="IndItem">) was being rendered even if there isn't enumchron info for that volume, so I added a conditional to take care of that unnecessary markup that was also adding whitespace to the table.Gayathri has approved the UI and a11y for this, so this PR is a second set of eyes of markup and php. This is staged on dev-3 if you want to look: https://dev-3.catalog.hathitrust.org/Record/000140237