Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gutter hover tooltip a11y improvements #5747

Merged
merged 1 commit into from
Feb 19, 2025
Merged

Conversation

babalaui
Copy link
Contributor

@babalaui babalaui commented Feb 19, 2025

Issue #, if available:

Description of changes:

  • made tooltip mouse hoverable
  • tooltip will still close on any keypress, unless the CTRL/Command are also being pressed at the same time, in case the user wants to copy text from the tooltip
  • improved tests by waiting for async tests to execute (some tests were failing on master too, if properly awaited)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Pull Request Checklist:

@babalaui babalaui requested a review from akoreman February 19, 2025 08:53
Copy link

codecov bot commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 90.69767% with 8 lines in your changes missing coverage. Please review.

Project coverage is 87.08%. Comparing base (09fba2e) to head (8fe9581).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
src/mouse/default_gutter_handler.js 73.33% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5747      +/-   ##
==========================================
+ Coverage   87.06%   87.08%   +0.01%     
==========================================
  Files         598      598              
  Lines       43722    43801      +79     
  Branches     7164     7171       +7     
==========================================
+ Hits        38067    38143      +76     
- Misses       5655     5658       +3     
Flag Coverage Δ
unittests 87.08% <90.69%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -524,6 +525,7 @@ class Gutter{
annotationNode.setAttribute("aria-label", ariaLabel);
annotationNode.setAttribute("tabindex", "-1");
annotationNode.setAttribute("role", "button");
annotationNode.setAttribute("aria-describedby", GUTTER_HOVER_TOOLTIP_ID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this set aria-describedby on all gutter annotations which are currently rendered, also on those which the open tooltip doesn't relate to? would that cause issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would indeed set it on all annotations, I dont see it being an issue though since the tooltip is the main way of viewing those annotations, so technically all of them are described by it. do you think its better to only add this attribute to the annotation currently described by the tooltip?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With aria-describedby always being set to the tooltip, when you keyboard navigate over the gutter annotations does it still properly read the aria-label of that annotation or does it read the tooltip (even when the tooltip isn't currently open)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah indeed, it seems that besides the aria label it will also read the tooltip, resulting in cases where it would read the tooltip from the previous annotation. I'll see if I find an easy fix for this, if not I'll remove this and tackle it in another PR.

// dont close tooltip in case the user wants to copy text from it (Ctrl/Meta + C)
if (e && e.type === "keydown" && (e.ctrlKey || e.metaKey))
return;
// dont close tooltip if mouse is on tooltip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reading this comment it reads as if when I hover over a gutter annotation and the tooltip shows, pressing escape doesn't close it (as the mouse is still on the tooltip). But in the test we add that seems to be what happens, am I misreading this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the tooltip will close when pressing escape even if mouse is on the tooltip, so I'll change the comment to better reflect that

@akoreman
Copy link
Contributor

I think the first bullet-point of the PR description is no longer accurate, could you remove it to prevent future confusion 🙂

@babalaui babalaui merged commit fbe3ddc into master Feb 19, 2025
3 checks passed
@babalaui babalaui deleted the fix_gutter_hover branch February 19, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants