feat: use custom aria labels for inputs with move announcements#9846
feat: use custom aria labels for inputs with move announcements#9846mikeharv wants to merge 1 commit intoRaspberryPiFoundation:v13from
Conversation
| ? input.getAriaLabelText()! | ||
| : input.getLabel(verbosity), | ||
| ); | ||
| .map((input) => input.getAriaLabelText() ?? input.getLabel(verbosity)); |
There was a problem hiding this comment.
This doesn't change anything functionally, but using nullish is safe because it expresses the intended “use this unless it's null” logic directly, while avoiding both a duplicate method call and an unnecessary non-null assertion.
There was a problem hiding this comment.
Interesting, I was under the impression that nullish coalescing was unsafe here because empty string evaluates to falsy but looks like the MDN documentation says that's not the case. Thanks, I wanted to do that to begin with. :D
| ? input.getAriaLabelText()! | ||
| : input.getLabel(verbosity), | ||
| ); | ||
| .map((input) => input.getAriaLabelText() ?? input.getLabel(verbosity)); |
There was a problem hiding this comment.
Interesting, I was under the impression that nullish coalescing was unsafe here because empty string evaluates to falsy but looks like the MDN documentation says that's not the case. Thanks, I wanted to do that to begin with. :D
The basics
The details
Resolves
Fixes #9836
Proposed Changes
This PR allows move announcements to use
Input.ariaLabelProviderwhen disambiguating connection candidates.If a provider is not provided, or one returns an empty string, we will fallback on the computed label using either the field labels for the input, or, if it's a statement input, a subset of inputs.
Test Coverage
A new test ensures that a move announcement
disambiguates with custom input labels.I also updated a few related tests to assert using string literals rather than duplicate computation logic that lived in the test file. This should make the tests easier to read and more likely to catch accidental regressions.