Skip to content
Snippets Groups Projects
Commit 8c8a2717 authored by Moritz Strohm's avatar Moritz Strohm
Browse files

fixed screen reader output for tooltips

parent d28f3aff
No related branches found
No related tags found
No related merge requests found
...@@ -596,7 +596,12 @@ function tooltipIcon($text, $important = false, $html = false): string ...@@ -596,7 +596,12 @@ function tooltipIcon($text, $important = false, $html = false): string
// render tooltip // render tooltip
$template = $GLOBALS['template_factory']->open('shared/tooltip'); $template = $GLOBALS['template_factory']->open('shared/tooltip');
return $template->render(compact('text', 'important', 'html')); return $template->render([
'text' => $text,
'important' => $important,
'html' => $html,
'tooltip_id' => md5($text) . random_bytes(4)
]);
} }
/** /**
...@@ -608,9 +613,13 @@ function tooltipIcon($text, $important = false, $html = false): string ...@@ -608,9 +613,13 @@ function tooltipIcon($text, $important = false, $html = false): string
function tooltipHtmlIcon($text, $important = false) function tooltipHtmlIcon($text, $important = false)
{ {
// render tooltip // render tooltip
$html = true;
$template = $GLOBALS['template_factory']->open('shared/tooltip'); $template = $GLOBALS['template_factory']->open('shared/tooltip');
return $template->render(compact('text', 'important', 'html')); return $template->render([
'text' => $text,
'important' => $important,
'html' => true,
'tooltip_id' => md5($text) . random_bytes(4)
]);
} }
/** /**
......
...@@ -41,7 +41,6 @@ $(document).on('mouseenter mouseleave focusin focusout', '[data-tooltip],.toolti ...@@ -41,7 +41,6 @@ $(document).on('mouseenter mouseleave focusin focusout', '[data-tooltip],.toolti
tooltip = new STUDIP.Tooltip(x, y, content); tooltip = new STUDIP.Tooltip(x, y, content);
data.tooltipObject = tooltip; data.tooltipObject = tooltip;
$(this).attr('aria-describedby', tooltip.id);
$(this).on('remove', function() { $(this).on('remove', function() {
tooltip.remove(); tooltip.remove();
......
<span class="tooltip tooltip-icon <? if ($important) echo 'tooltip-important'; ?>" data-tooltip <? if (!$html) printf('title="%s"', htmlReady($text)) ?> tabindex="0"> <span class="tooltip tooltip-icon <? if ($important) echo 'tooltip-important'; ?>"
data-tooltip <? if (!$html) printf('title="%s"', htmlReady($text)) ?>
tabindex="0" aria-describedby="tooltip_<?= htmlReady($tooltip_id) ?>">
<? if ($html): ?> <? if ($html): ?>
<span class="tooltip-content"><?= $text ?></span> <span class="tooltip-content"><?= $text ?></span>
<? endif; ?> <? endif; ?>
</span> </span>
<span id="tooltip_<?= htmlReady($tooltip_id) ?>" class="sr-only"><?= htmlReady($text) ?></span>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment