Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign uptoBeActiveDescendant #207
toBeActiveDescendant #207
Comments
|
Hi, thanks for opening this issue and providing so much detail I follow the general gist of it but have some concern regarding the name. The name implies that this is "just" The listbox could still have the You're essentially suggesting: - expect(listbox).toHaveFocus();
- expect(listbox).toHaveAttribute('aria-activedescendant', option1.getAttribute('id'))
+ expect(option1).toBeActiveDescendant();Personally I would prefer a composite assertion (following the composite nature of the widget): - expect(listbox).toHaveFocus();
- expect(listbox).toHaveActiveDescendant(option1)and then maybe add an additional helper with a bit more verbose name such as Regarding implementation:
|
|
I'm all for it. There are interesting alternative ways to put it in @eps1lon's response. I still think I prefer what @diegohaz originally suggested. That is, I prefer As for the name, No strong opinions here, I'm open to be challenged in all this. |
I generally want to optimize for readability. It's the thing we do more often than writing. |
|
Oh ok. Fair enough. But in my case I do not see it less readable. Just wanted to clear that up. Because I too favor readability. What is it less readable about the proposed api? Anyway, let’s wait for @diegohaz’s thoughts on this. In any case my concerns are kind of nit picks because in any of these forms this app will be a welcome feature. No strong feelings either way. |
So readable was probably the wrong word. "reasonable" or "being a test that I can follow" may be more appropriate. It may be unrelated but I've recently read some "older" test of mine using |
|
Thank you for the quick and thoughtful responses! :) I see how The feature I'm proposing here is more an equivalent to I was also curious about the term Found references on the MDN docs though: https://developer.mozilla.org/en-US/docs/Web/Accessibility/Keyboard-navigable_JavaScript_widgets#Managing_focus_inside_groups
An audacious alternative is to enhance |
These match different CSS pseudo-classes so I wouldn't merge these. It's oftentimes intended to outline the widget container and their active descendant. |
Ah, feel free to take it! :) |
|
I may start to work on this soon, and I'm still torn on how to name it. Though it's not just the name conundrum, but also how the API would work. Will outline the alternatives I distill from the discussion so far. Let me know if something here is being misrepresented. Also, would like to know if you see a path forward where we could offer ore than one of these alternatives at the same time (they do not seem to be strictly conflicting, but it could be confusing). 1.
|

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

Describe the feature you'd like:
I'm testing composite components that use
aria-activedescendantto move focus. I would like to test whether some item is "virtually" focused or not after pressing arrow keys:Suggested implementation:
I'm not sure about the code specific to create jest matchers, but this the utility I'm currently using:
Alternative implementations could also check for
aria-selected="true"on theelement, but from what I see, not all implementations includearia-selected, whereasaria-activedescendantis mandatory on the focused element.Describe alternatives you've considered:
I'm currently using the utility function above. It's simple, but, since there are not so many people who know how
aria-activedescendantworks (for example, that it should be in the currentactiveElement), I guess the community would benefit from a matcher like that.Teachability, Documentation, Adoption, Migration Strategy:
toBeActiveDescendantThis allows you to check whether the given element is currently referenced in the
aria-activedescendantattribute on the element which currently has DOM focus.Examples