From adac1a2867a61f6cd20c21e6a4f26ade7cad1e1b Mon Sep 17 00:00:00 2001 From: Moritz Strohm <strohm@data-quest.de> Date: Tue, 28 Sep 2021 17:33:57 +0200 Subject: [PATCH] added tabindex for tooltips generated by tooltip2 or tooltipIcon functions --- lib/visual.inc.php | 1 + resources/assets/javascripts/bootstrap/tooltip.js | 8 ++++---- templates/shared/tooltip.php | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/visual.inc.php b/lib/visual.inc.php index d578587b3ac..ae1f9d89bfc 100644 --- a/lib/visual.inc.php +++ b/lib/visual.inc.php @@ -623,6 +623,7 @@ function tooltip2($text, $with_alt = TRUE, $with_popup = FALSE) { $ret['alt'] = $text; } $ret['title'] = $text; + $ret['tabindex'] = '0'; return $ret; } diff --git a/resources/assets/javascripts/bootstrap/tooltip.js b/resources/assets/javascripts/bootstrap/tooltip.js index 8f97d6cbf36..d99879ce591 100644 --- a/resources/assets/javascripts/bootstrap/tooltip.js +++ b/resources/assets/javascripts/bootstrap/tooltip.js @@ -10,10 +10,10 @@ var timeout = null; STUDIP.Tooltip.threshold = 6; -$(document).on('mouseenter mouseleave', '[data-tooltip],.tooltip:has(.tooltip-content)', function(event) { +$(document).on('mouseenter mouseleave focusin focusout', '[data-tooltip],.tooltip:has(.tooltip-content)', function(event) { let data = $(this).data(); - const visible = event.type === 'mouseenter'; + const visible = event.type === 'mouseenter' || event.type === 'focusin'; const offset = $(this).offset(); const x = offset.left + $(this).outerWidth(true) / 2; const y = offset.top; @@ -61,8 +61,8 @@ $(document).on('mouseenter mouseleave', '[data-tooltip],.tooltip:has(.tooltip-co } else { timeout = setTimeout(() => data.tooltipObject.hide(), delay); } -}).on('mouseenter', '.studip-tooltip', () => { +}).on('mouseenter focusin', '.studip-tooltip', () => { clearTimeout(timeout); -}).on('mouseleave', '.studip-tooltip', function() { +}).on('mouseleave focusout', '.studip-tooltip', function() { $(this).hide(); }); diff --git a/templates/shared/tooltip.php b/templates/shared/tooltip.php index 3443c98c3bd..a97c73f2759 100644 --- a/templates/shared/tooltip.php +++ b/templates/shared/tooltip.php @@ -1,4 +1,4 @@ -<span class="tooltip tooltip-icon <? if ($important) echo 'tooltip-important'; ?>" data-tooltip <? if (!$html) printf('title="%s"', htmlReady($text)) ?>> +<span class="tooltip tooltip-icon <? if ($important) echo 'tooltip-important'; ?>" data-tooltip <? if (!$html) printf('title="%s"', htmlReady($text)) ?> tabindex="0"> <? if ($html): ?> <span class="tooltip-content"><?= $text ?></span> <? endif; ?> -- GitLab