Skip to content

Commit 2030ba3

Browse files
Added escape functionality to tooltip behavior for accessibility (#10634)
1 parent 1e090f8 commit 2030ba3

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/NuGetGallery/Scripts/gallery/common.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,4 +789,18 @@
789789
$(document).on('mouseleave focusout', '.tooltip-target', function () {
790790
$(this).find('.tooltip-wrapper').removeClass('show');
791791
});
792+
793+
// allow users to escape out of tooltips (accessibility requirement)
794+
// project has two different tooltip implementations, adding a fix for both
795+
$(document).on('keydown', '.tooltip-target', function (event) {
796+
if (event.key === 'Escape' || event.keyCode === 27) {
797+
$(this).find('.tooltip-wrapper').removeClass('show');
798+
}
799+
});
800+
801+
$(document).on('keydown', '[data-toggle="tooltip"]', function (event) {
802+
if (event.key === 'Escape' || event.keyCode === 27) {
803+
$(this).tooltip('hide');
804+
}
805+
});
792806
}());

0 commit comments

Comments
 (0)