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

Make Elements accessible using keyboard (issue 1162) #1168

Open
wants to merge 5 commits into
base: staging
Choose a base branch
from

Conversation

lemondevxyz
Copy link
Contributor

@lemondevxyz lemondevxyz commented Jul 31, 2023

This PR request basically fixes issue #1162. It tackles every step in the issue, namely:

  • Settings Page sidebar
  • Teams page (content and sidebar)
  • User list (only documentation was visible before this PR)
  • Contacts list

Tested on Google Chrome, Desktop, Linux.

Do note that the fixes are in several commits, be sure to check the commits' description for more information.

Basically, all browsers have this little neat feature that allows users
to select elements by pressing the Tab key. It selects the top element and
goes down to the right by pressing Tab again. Most of these elements that
are selected are interactive elements. Sometimes, interactive elements
are not selected due to some markup issues.

This commit makes it possible to select user menu through the tab key,
thereby making buttons in the user menu a lot more accessible for users
who only have keyboards. The changes made are as follows:

1. Make all user menu buttons have a tabindex attribute
2. When the enter key is pressed, evaluate the necessary callback
The Contacts page is the second previously less accessible component in
issue 1162. This commit hooks all the necessary "keydown" and "keypress"
events and the "tabindex" attribute.

Beyond that, this commit has one change that is important to denote. That is, the sorting mechanism of the contacts page. The sorting mechanism used to be done through the CSS attribute: "order". However, this only changes the visual order not the functional element order. This particularily affects keyboard navigation and makes it completely random.

The new change of this commit makes the sorting method through jQuery's sort function. Other methods simply erased away very important callbacks and other internal DOM properties that erase away much of the functionality. This approach is preferred because it reduces code complexity.
Beside making linter silent and /teams keyboard accessible, there was
a modification to the styling of the messaging elements that allowed
/contacts to be sorted through Javascript.

There was another modification to the styling of the drive to make the
keyboard focus border visible. Lastly, most of the modification done on
./www/teams/inner.js was through this acme command (that uses sed):

Edit , | sed 's|.click(function () {|.on("click keypress", function (e) {\nif(e.type === "keypress" \&\& e.originalEvent.which !== 13) return;|g'

The command above basically replaced all instance of "click(" to an
event handler that subscribes to "keypress" that starts with checking
that the enter key was entered. If not, it just stops the handler.
Making settings sidebar keyboard accessible was as simple as:
1. Modifying the click to an on event
2. Adding 'tabindex'

It was simple because all the categories were generated through the
map function.
This commit basically makes any element in the toolbar that is selected
by the keyboard visible.
@ghost ghost assigned davidbenque Jul 31, 2023
@ghost ghost requested a review from yflory July 31, 2023 11:58
@ghost ghost added Accessibility Make software available to everyone UI/UX Interfaces & user experience labels Jul 31, 2023
@wginolas
Copy link
Contributor

wginolas commented Aug 7, 2023

Thanks lemondevxyz for the PR! In my opinion we should find a solution with less code duplication. @yflory will be available in a week. We can discuss this topic then.

@lemondevxyz
Copy link
Contributor Author

I could see an application wide solution being made through wrapping jQuery's .click with an event handles that handles both mouse clicks and the enter key.

Or, a solution could be in the form of a button component similar to the UIElements.createButton function in ./www/common/common-ui-elements.js. If no code refactoring is needed one could simply scan all elements using jQuery after the document has loaded and modify all elements with a onclick event to add all the necessary attributes to make those elements keyboard selectable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accessibility Make software available to everyone UI/UX Interfaces & user experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants