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

[ISSUE#1881][MAS2.1.2][Keyboard Navigation- Welcome Tab screen] Focus gets trapped on first and last element of the page when user navigates through the page #2001

Merged
merged 16 commits into from
Nov 26, 2019

Conversation

denscollo
Copy link
Contributor

Solves #1881

Description

Fixes how the focus gets trapped between the last and the first element of the pane.

Changes made

We added a new condition to the EventHandlers class which will manage the focus when the emulator is running in macOS. Also, we included two auxiliary methods to find the first and last elements of the active pane and be able to move the focus between them.

Additionally, we added two unit tests to cover the new keydown event.

Testing

In the following image, you can see how the focus goes from the last element of the pane to the first when navigating with Tab key and vice-versa when using Shift+Tab navigation:

FocusTrap

@coveralls
Copy link

coveralls commented Nov 21, 2019

Coverage Status

Coverage increased (+0.08%) to 68.75% when pulling 50b4d5c on fix/focus-trap-in-mac-navigation into cb08d7d on master.

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@corinagum corinagum left a comment

Choose a reason for hiding this comment

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

Thanks for the help! Just a couple of small changes.

packages/app/client/src/utils/eventHandlers.ts Outdated Show resolved Hide resolved
@denscollo
Copy link
Contributor Author

@corinagum if we move lines 142 & 143 to the ones that you told us, the isFirstElement and isLastElement variables are not going to work. If you want us to move those line, we need to update the if clause to be something like:
if (shiftPressed && document.activeElement === document.querySelector('nav').firstElementChild as HTMLElement) { }

And something similar would happen to the other if clause, since it uses lastDecendants to obtain the lastElement.

Let us know if you want us to proceed with this change.

@corinagum corinagum merged commit 2d88a90 into master Nov 26, 2019
@tonyanziano tonyanziano deleted the fix/focus-trap-in-mac-navigation branch November 26, 2019 18:23
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.

None yet

6 participants