feat: add accessibility labels to torch and cancel buttons#45
feat: add accessibility labels to torch and cancel buttons#45alexgerardojacinto wants to merge 2 commits into
Conversation
The torch and cancel buttons were icon-only with no alternative text, so screen readers could not announce them. Add default English accessibility labels and expose optional cancelButtonAccessibilityLabel, torchButtonOnAccessibilityLabel and torchButtonOffAccessibilityLabel scan parameters so consumers can customize/localize them. Closes #44
When a label is not provided (nil/empty), no accessibility label is applied, keeping the previous behavior unchanged. The English default labels are removed; consumers supply the (localized) labels via the scan parameters.
OS-pedrogustavobilro
left a comment
There was a problem hiding this comment.
I tested and it worked fine, my comments are more related to documentation and clarifications
| public let hint: OSBARCScannerHint? | ||
|
|
||
|
|
||
| /// Optional accessibility label for the cancel button. `Nil` or empty value uses the library's default. |
There was a problem hiding this comment.
I was looking at this and was a bit confused. You talk in a few places here about "library's default", which from what I read, the default is just no label. While that makes sense, the whole "Nil or empty value uses the library's default." sentence makes it sound like it would provide an actual default label when the consumer doesn't provide anything. To me it feels like that sentence doesn't need to be there at all.
This also applies to the descriptions you added in the capacitor plugin.
| /// Optional accessibility label for the cancel button. `Nil` or empty value uses the library's default. | ||
| public let cancelButtonAccessibilityLabel: String? | ||
|
|
||
| /// Optional accessibility label for the torch button when the torch is on. `Nil` or empty value uses the library's default. | ||
| public let torchButtonOnAccessibilityLabel: String? | ||
|
|
||
| /// Optional accessibility label for the torch button when the torch is off. `Nil` or empty value uses the library's default. | ||
| public let torchButtonOffAccessibilityLabel: String? |
There was a problem hiding this comment.
Should add these parameters to the README, as we have for others.
Description
The Torch and Cancel buttons are icon-only with no alternative text, so VoiceOver can't announce them. This PR adds the ability to set that alternative text.
OSBARCScanParametersthat set the accessibility label read by screen readers:cancelButtonAccessibilityLabeltorchButtonOnAccessibilityLabel(torch on)torchButtonOffAccessibilityLabel(torch off).accessibility(label:).Context
An accessibility audit flagged that the Torch and Cancel buttons have no alternative text, so they are announced incorrectly by screen readers. This exposes the labels as inputs so consumers can provide localized alternative text.
Closes #44
Type of changes
Platforms affected
Tests
Screenshots (if appropriate)
N/A
Checklist