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

Fixes Spaces Menu Keyboard and Screen Reader Navigation #134454

Merged

Conversation

jeramysoucy
Copy link
Contributor

@jeramysoucy jeramysoucy commented Jun 15, 2022

Fixes #130898

Summary

Refactor of the Spaces popover implementation using the EuiSelectable component. This component handles all of the focus, tabbing, and search behaviors innately - resolving previous navigation issues, and keeping a consistent UX in Kibana.

A relevant demonstration of the component can be found here.

Minor Behavior Change

When the user selects the already active space in the menu without any options (shift, ctrl/cmd, middle click), they will not be redirected to the home screen and instead remain on the current screen. The previous implementation would perform a full page redirect to the home screen, even if the user selected the space that is already active.

Testing Non-Searchable Mode:

  1. Create up to 6 spaces, for a maximum total of 7 including the default space
  2. Verify the spaces navigation button avatar reflects the current active space
  3. Click the spaces navigation button, verify a popover with heading "Your spaces" appears displaying all spaces with avatars on the left and a "Manage spaces" button at the bottom.
  4. Verify the active space is checked.
  5. Verify that the tab key toggles focus between the popover frame, the spaces list, and the manage spaces button.
  6. Verify that that the up and down arrow keys can be used to navigate the spaces list when the spaces list is in focus.
  7. Verify that selection will wrap when the arrow keys are used at the list limits (last option to first option, first option to last).
  8. Verify that pressing enter when the manage spaces button is in focus causes the manage space app to load.
  9. Verify that pressing enter when the spaces list is in focus and a non-active space is selected causes the select space to become the active space (full page refresh).
  10. Verify that holding shift and pressing enter when the spaces list is in focus and a non-active space is selected causes the select space to open in a new window.
  11. Verify that holding command (control on Windows) and pressing enter when the spaces list is in focus and a non-active space is selected causes the select space to open in a new tab.
  12. Verify that using the mouse to click on a non-active space in the spaces list causes the select space to become the active space (full page refresh).
  13. Verify that holding shift and clicking on a non-active space in the spaces causes that space to open in a new window.
  14. Verify that holding command (control on Windows) and clicking on a non-active space in the spaces list causes that space to open in a new tab.
  15. Verify the spaces navigation popover can be closes by clicking outside the popover, pressing escape, or by clicking the spaces navigation button when the popover is already open.

Testing Searchable Mode:

  1. Create at least 7 spaces, for a minimum total of 8 including the default space
  2. Verify the spaces navigation button avatar reflects the current active space
  3. Click the spaces navigation button, verify a popover with a search input appears with placeholder text "Find a space", verify the popover also contains a list of all spaces with avatars on the left and a "Manage spaces" button at the bottom.
  4. Verify the active space is checked.
  5. Verify that the tab key toggles focus between the popover frame, the spaces search input, and the manage spaces button.
  6. Verify that that the up and down arrow keys can be used to navigate the spaces list when the spaces search field is in focus.
  7. Verify that selection will wrap when the arrow keys are used at the list limits (last option to first option, first option to last).
  8. Verify that pressing enter when the manage spaces button is in focus causes the manage space app to load.
  9. Verify that typing text into the spaces search field causes the options in the spaces list to be filtered based on the input.
  10. Verify that pressing enter when the spaces search field is in focus and a non-active space is selected causes the select space to become the active space (full page refresh).
  11. Verify that holding shift and pressing enter when the spaces search field is in focus and a non-active space is selected causes the select space to open in a new window.
  12. Verify that holding command (control on Windows) and pressing enter when the spaces search list is in focus and a non-active space is selected causes the select space to open in a new tab.
  13. Verify that using the mouse to click on a non-active space in the spaces list causes the select space to become the active space (full page refresh).
  14. Verify that holding shift and clicking on a non-active space in the spaces causes that space to open in a new window.
  15. Verify that holding command (control on Windows) and clicking on a non-active space in the spaces list causes that space to open in a new tab.
  16. Verify the spaces navigation popover can be closes by clicking outside the popover, pressing escape, or by clicking the spaces navigation button when the popover is already open.

Testing The Screen Reader:

  1. Enable a screen reader
  2. Verify that when the spaces navigation header button is in focus that the reader states the currently selected space and the purpose of the button.
  3. Open the spaces navigation button with the return key.
  4. Verify the popover opens.
  5. Use the keyboard to navigate into the popover.
  6. Verify the screen reader states that you're in a text entry field of a list when the search field is in focus.
  7. When traversing the spaces list using the up and down keys, verify the screen reader state the selected option in the list.
  8. When using the search field, verify the screen reader states the entered text and number of options.
  9. Verify the screen reader states "manage spaces button" when the manage space button is in focus.
  10. Verify the screen reader still works appropriately when the search field is not present (7 or fewer spaces).

Note: in my testing I found Safari to exhibit undesirable screen-reader and tabbing behavior both with the new Spaces navigation implementation and the above linked EUI demonstration.

@jeramysoucy jeramysoucy changed the title Fix Spaces Menu Keyboard and Screen Reader Navigation Fixed Spaces Menu Keyboard and Screen Reader Navigation Jun 15, 2022
@jeramysoucy jeramysoucy changed the title Fixed Spaces Menu Keyboard and Screen Reader Navigation Fixes Spaces Menu Keyboard and Screen Reader Navigation Jun 15, 2022
@jeramysoucy jeramysoucy added Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! Feature:Security/Spaces Platform Security - Spaces feature v8.4.0 release_note:fix labels Jun 16, 2022
@jeramysoucy jeramysoucy force-pushed the fix-spaces-menu-kb-and-screen-reader-nav branch from dff1718 to f30a63b Compare June 16, 2022 08:07
@jeramysoucy
Copy link
Contributor Author

jeramysoucy commented Jun 16, 2022

Waiting on #133927 (and now #135373) for shift/ctrl/cmd click functionality.

@jeramysoucy jeramysoucy force-pushed the fix-spaces-menu-kb-and-screen-reader-nav branch 3 times, most recently from a96db6a to 6072c77 Compare July 12, 2022 09:02
@jeramysoucy jeramysoucy force-pushed the fix-spaces-menu-kb-and-screen-reader-nav branch 2 times, most recently from dfc5b47 to 0f00360 Compare July 13, 2022 06:28
@jeramysoucy
Copy link
Contributor Author

Awaiting #136405 to accommodate keyboard event args.

@jeramysoucy
Copy link
Contributor Author

@elastic/kibana-design Looking for some feedback on this - we've changed the behavior of the space menu to NOT reload/go to home when the currently active space is re-selected. In order to provide some corresponding visual feedback, we're now highlighting the active space in the menu, and if it is selected the popover simply closes and the user remains on the current page.
new spaces nav

@MichaelMarcialis
Copy link
Contributor

@elastic/kibana-design Looking for some feedback on this - we've changed the behavior of the space menu to NOT reload/go to home when the currently active space is re-selected. In order to provide some corresponding visual feedback, we're now highlighting the active space in the menu, and if it is selected the popover simply closes and the user remains on the current page.

Thanks for the ping! Seeing as the space selection menu uses an EuiContextMenu, there's actually an existing pattern you can use to indicate current selection in context menus using a check icon. Give the example in the EUI docs a look and let us know if you need further assistance.

image

@jeramysoucy
Copy link
Contributor Author

Seeing as the space selection menu uses an EuiContextMenu

Thanks for checking this out @MichaelMarcialis! We're actually using EuiSelectable now. This PR is for refactoring from the context menu to use the selectable component. I am using the EUI Header example as reference, which does highlight the active space...so that perhaps is the confirmation I needed.

@MichaelMarcialis
Copy link
Contributor

We're actually using EuiSelectable now.

Ah, great! The EuiSelectable component also has the ability to indicate current selection with a check. Have a look at the single selection example in the EUI docs.

image

@jeramysoucy
Copy link
Contributor Author

jeramysoucy commented Jul 21, 2022

The EuiSelectable component also has the ability to indicate current selection with a check

@MichaelMarcialis Is a checkmark necessary or highly preferred in this case? I've been following the style of the EUI Header example, which utilizes EuiSelectable without checkmarks, but with highlighting, to demonstrate the same purpose (spaces navigation in an application header).

EDIT: I've added the checkmark, as item highlighting does not persist with keyboard navigation.

…ard and mouse event details (shift, ctrl, middle click).
…tests for nav control popover.

Eliminated tab selection of popover panel itself. Tested screen reader extensively with Chrome on Mac.
Note: Safari screen reader and tabbing behavior is not consistent and differs significantly from Chrome.
…ions (shift, ctrl, etc.) is not yet working - event argument in selectable onChange is null for keyboard events.
@jeramysoucy jeramysoucy marked this pull request as ready for review July 26, 2022 14:46
@jeramysoucy jeramysoucy requested review from a team as code owners July 26, 2022 14:46
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

@jeramysoucy
Copy link
Contributor Author

@elasticmachine merge upstream

@legrego legrego requested a review from thomheymann July 26, 2022 16:53
Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

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

ML edit LGTM

Copy link
Contributor

@thomheymann thomheymann left a comment

Choose a reason for hiding this comment

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

Looks great. Thanks for this. Tested locally and working as expected.

Couple minor comments.

@jeramysoucy
Copy link
Contributor Author

@elasticmachine merge upstream

@jeramysoucy
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
security 504.1KB 503.6KB -496.0B
spaces 152.6KB 152.7KB +173.0B
total -323.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
spaces 20.3KB 20.3KB +42.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@thomheymann thomheymann left a comment

Choose a reason for hiding this comment

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

Nice one! Looks good to me!

@jeramysoucy jeramysoucy merged commit 31c2c0f into elastic:main Aug 2, 2022
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 2, 2022
* Refactor of spaces pop-over using EuiSelectable.

* Updated to use Eui type instead of interface.

* Reorganization of code, began to add EuiSelectableOnChangeEvent usage.

* Repathed import after rebase

* Integrates the EuiSelectableOnChangeEvent argument to intercept keyboard and mouse event details (shift, ctrl, middle click).

* Resolves missing property error in nav popover test.

* Handles reintroduction of translated strings into empty and no match messages of the Spaces selectable.

* Refactor of spaces_popover_list to use EuiSelectable, resolves keyboard navigation.

* Updated tests for spaces popover list and created more comprehensive tests for nav control popover.
Eliminated tab selection of popover panel itself. Tested screen reader extensively with Chrome on Mac.
Note: Safari screen reader and tabbing behavior is not consistent and differs significantly from Chrome.

* Adjuted focus behavior in popover. Rebased to use EUI 60.1.2

* Fixed typo in roles spaces popover list. Keyboard navigation with options (shift, ctrl, etc.) is not yet working - event argument in selectable onChange is null for keyboard events.

* Updated comments.

* Fixes issue with keyboard operation of manage spaces button of spaces_menu. Fixes naming of translated string resources in spaces_popover_list.

* Fixes name of existing string reference in spaces_menu.

* Fixes CSS selector calls in spaces functional test.

* Fixes space selection in functional tests.

* Fixes popover close issue on Manage spaces button click. Implements check for re-selecting active space. Implements popover close when opening a space in a new window.

* Updated jest snapshot for spaces nav test.

* Fixes ML functional tests to accommodate new behavior when selecting already active space.

* Added active space highlight feedback. Removed state from spaces menu class.

* Rebased, added check mark for active space, resolved activeOption keyboard nav break from EUI update

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* Fixes initial active space highlight which was caused by initial empty spaces state in nav_control_popover and loading render logic.
Removes isLoading from spaces_menu - no longer necessary, SpacesDescription is now used during loading.

* Added debug output of actual URL in route expects.

* Added loading message to spaces navigation.

* Updated jest snapshot.

* Addressed flaky test behavior related to space menu nav. Implemented review feedback suggestions.

* Adds sleep to functional test UI interactions.

* Replaced use of any with ExclusiveUnion for search props of EuiSelectable.
Resolved flaky test for spaces nav.

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 31c2c0f)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.4

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Aug 2, 2022
…37859)

* Refactor of spaces pop-over using EuiSelectable.

* Updated to use Eui type instead of interface.

* Reorganization of code, began to add EuiSelectableOnChangeEvent usage.

* Repathed import after rebase

* Integrates the EuiSelectableOnChangeEvent argument to intercept keyboard and mouse event details (shift, ctrl, middle click).

* Resolves missing property error in nav popover test.

* Handles reintroduction of translated strings into empty and no match messages of the Spaces selectable.

* Refactor of spaces_popover_list to use EuiSelectable, resolves keyboard navigation.

* Updated tests for spaces popover list and created more comprehensive tests for nav control popover.
Eliminated tab selection of popover panel itself. Tested screen reader extensively with Chrome on Mac.
Note: Safari screen reader and tabbing behavior is not consistent and differs significantly from Chrome.

* Adjuted focus behavior in popover. Rebased to use EUI 60.1.2

* Fixed typo in roles spaces popover list. Keyboard navigation with options (shift, ctrl, etc.) is not yet working - event argument in selectable onChange is null for keyboard events.

* Updated comments.

* Fixes issue with keyboard operation of manage spaces button of spaces_menu. Fixes naming of translated string resources in spaces_popover_list.

* Fixes name of existing string reference in spaces_menu.

* Fixes CSS selector calls in spaces functional test.

* Fixes space selection in functional tests.

* Fixes popover close issue on Manage spaces button click. Implements check for re-selecting active space. Implements popover close when opening a space in a new window.

* Updated jest snapshot for spaces nav test.

* Fixes ML functional tests to accommodate new behavior when selecting already active space.

* Added active space highlight feedback. Removed state from spaces menu class.

* Rebased, added check mark for active space, resolved activeOption keyboard nav break from EUI update

* [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix'

* Fixes initial active space highlight which was caused by initial empty spaces state in nav_control_popover and loading render logic.
Removes isLoading from spaces_menu - no longer necessary, SpacesDescription is now used during loading.

* Added debug output of actual URL in route expects.

* Added loading message to spaces navigation.

* Updated jest snapshot.

* Addressed flaky test behavior related to space menu nav. Implemented review feedback suggestions.

* Adds sleep to functional test UI interactions.

* Replaced use of any with ExclusiveUnion for search props of EuiSelectable.
Resolved flaky test for spaces nav.

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 31c2c0f)

Co-authored-by: Jeramy Soucy <jeramy.soucy@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Security/Spaces Platform Security - Spaces feature release_note:fix Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v8.4.0 v8.5.0
Projects
None yet
7 participants