-
Notifications
You must be signed in to change notification settings - Fork 278
Closed
Description
Problem
Some of our a11y queries are underwhelming:
getByA11yState({ disabled: true })- does not give any control over which control we are trying to find. Can be problematic if there are 2+ controls with matching state, we also might accidentally match another disabled control leading to false negative result.getByA11yValue({ min: 100 })- similar issues
Note: these queries have no counterpart in RTL.
Other queries are somewhat more useful, but still less powerful than getByRole:
getByLabelTextgetByHintText
Users are generally better server by using getByRole with name and state props like disabled, selected, etc.
Note: this queries have counterpart in the RTL world (LabelText) or have similar semantic (HintText).
Proposed solution
- Add a11y value & hint props support to
getByRolein order to make it more versatile - Deprecate
*ByA11yStateand*ByA11yValuequeries, and display message to usegetByRolewith appropriate parameters. - Keep
*ByLabelTextand*ByHintTexttext as lightweight queries, but mention in the docs that we rather suggest usinggetByRolewith proper additional attributes.
Impact
Soft deprecating, i.e. displaying deprecating warning to console, is not a breaking change, so we might do with minor/feature update.
We then should remove *ByA11yState and *ByA11yValue in the next or next^2 release.
MattAgn
Metadata
Metadata
Labels
No labels