Testing keyboard navigation of nested FocusZone components with jest and testing library's userEvent #21943
Zeddox
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
While fixing some accessibility bugs, we needed to add regression test cases for keyboard navigation that involved a table with nested
FocusZone
components.We're using
@fluentui/react
version8.56.0
.Top Level FocusZone:
Nested FocusZones:
Our test case for testing the keyboard navigation has this code:
Our test was failing to focus the first interactive element within the nested focus zone. After debugging the code path for shouldEnterInnerZone, we came across a line within the
utilities/focus.ts
module that checks for an element's visibility and a condition for anisVisible
property on the HTMLElement. IsVisible property checkAfter we added
(HTMLElement.prototype as any).isVisible = true;
to our test suite's beforeEach, the inner focus zone is entered with the right arrow key and our test is passing.Not sure if this is documented anywhere, but hopefully it helps anyone else trying to perform this kind of test.
Beta Was this translation helpful? Give feedback.
All reactions