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: improve aria attributes of popup elements #5739

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

babalaui
Copy link
Contributor

@babalaui babalaui commented Feb 4, 2025

Issue #, if available:

Description of changes:

  • Set aria attributes to all visible elements of the popup, not just the selected one, as specified in https://www.w3.org/WAI/ARIA/apg/patterns/listbox/#roles_states_properties
  • add the meta text to the aria-label if present
  • add role="mark" to ace_completion-highlight spans, to also show that the text is highlighted for screen reader users
  • cleanup selected property even if there is not new selected element

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 nightwing February 4, 2025 11:57
Copy link

codecov bot commented Feb 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.06%. Comparing base (ef8b1f0) to head (f7032e2).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5739   +/-   ##
=======================================
  Coverage   87.06%   87.06%           
=======================================
  Files         598      598           
  Lines       43719    43722    +3     
  Branches     7164     7164           
=======================================
+ Hits        38064    38067    +3     
  Misses       5655     5655           
Flag Coverage Δ
unittests 87.06% <100.00%> (+<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.

var t = popup.renderer.$textLayer;
for (var row = t.config.firstRow, l = t.config.lastRow; row <= l; row++) {
const popupRowElement = /** @type {HTMLElement|null} */(t.element.childNodes[row - t.config.firstRow]);
const ariaLabel = `${popup.getData(row).caption || popup.getData(row).value}${popup.getData(row).meta ? `, ${popup.getData(row).meta}` : ''}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const ariaLabel = `${popup.getData(row).caption || popup.getData(row).value}${popup.getData(row).meta ? `, ${popup.getData(row).meta}` : ''}`;
const rowData = popup.getData(row);
const ariaLabel = `${rowData.caption || rowData.value}${rowData.meta ? `, ${rowData.meta}` : ''}`;

@@ -424,7 +424,15 @@ class Text {
span.className = classes;
span.appendChild(valueFragment);

parent.appendChild(span);
if (token.type === "completion-highlight") {
Copy link
Member

Choose a reason for hiding this comment

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

this does not belong in text.js which is the editor renderer, and should not contain code specific to the popup. What are you trying to accomplish with this code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this code aims to improve accessibility, the reason being that screen reader users will not be aware of the presence of the highlighted text otherwise. is there any other place in the code you would recommend me to add this logic to?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to role=mark instead of mark element, and set it from the afterRender hook where other popup aria attributes are handled

@babalaui babalaui requested review from xyos and nightwing February 4, 2025 15:39
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.

4 participants