[DON-3563] Add contentDescription to BpkSearchInputControl - #2786
Conversation
Uses clearAndSetSemantics on the control field so TalkBack announces a single, explicit description instead of a merged one built from child nodes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Generated by 🚫 Danger Kotlin against c217653 |
There was a problem hiding this comment.
Pull request overview
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds an explicit accessibility label to BpkSearchInputControl so TalkBack announces a single, intended description instead of a merged string from child semantics.
Changes:
- Introduces a required
contentDescriptionparameter onBpkSearchInputControland threads it intoBpkControlFieldImpl. - Applies
clearAndSetSemanticson the control field container to override merged child semantics. - Updates demo story call sites with example content descriptions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| backpack-compose/src/main/kotlin/net/skyscanner/backpack/compose/textfield/internal/BpkControlFieldImpl.kt | Overrides container semantics to provide a single accessible label. |
| backpack-compose/src/main/kotlin/net/skyscanner/backpack/compose/searchinputcontrol/BpkSearchInputControl.kt | Makes contentDescription a required public API param and forwards it to the internal control field. |
| app/src/main/java/net/skyscanner/backpack/demo/compose/SearchInputControlStory.kt | Updates demo usage with example content descriptions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| fun BpkSearchInputControl( | ||
| inputText: String, | ||
| inputHint: String, | ||
| contentDescription: String, | ||
| prefix: Prefix, |
There was a problem hiding this comment.
It is fine, there is no useage for SearchInputControl in the main app at the moment
There was a problem hiding this comment.
Change label to major please
| isFocused = currentFocusedIndex == 0, | ||
| style = style, | ||
| docking = Docking.Top, | ||
| contentDescription = "Departing from London", |
| isFocused = currentFocusedIndex == 1, | ||
| style = style, | ||
| docking = Docking.Middle, | ||
| contentDescription = "Where to?", |
| isFocused = currentFocusedIndex == 2, | ||
| style = style, | ||
| docking = Docking.Middle, | ||
| contentDescription = "Leaving on Thurs 9 May, and returning Fri 29 May, 2025", |
| isFocused = currentFocusedIndex == 3, | ||
| style = style, | ||
| docking = Docking.Bottom, | ||
| contentDescription = "1 adult travelling", |
There was a problem hiding this comment.
peterliu (@peterInTown) plus 1 to copilot, we should be using stringResource instead. other stories use stringResource, lets not introduce hardcoded strings
mldtms
left a comment
There was a problem hiding this comment.
it's a demo so I guess plan strings are accepted here, so it's okay.
Henrik Sym (henrik-sky)
left a comment
There was a problem hiding this comment.
The clear action is visually present but inaccessible. BpkControlFieldImpl applies clearAndSetSemantics to the whole field, which hides descendant semantics. I verified this on the running story with BpkClearAction: the X is visible, but the accessibility tree exposes only one clickable/focusable node, Departing from London; there is no Clear departure airport action/node. That prevents TalkBack users from discovering or activating clear. Please preserve/expose the clear-action semantics while retaining the single field label, and avoid wiping caller-provided semantics.
Co-authored-by: Claude <noreply@anthropic.com>
Generated by 🚫 Danger Kotlin against cdc6642 |
Generated by 🚫 Danger Kotlin against 91f996d |
Henrik Sym (henrik-sky)
left a comment
There was a problem hiding this comment.
Approved as major change
Summary
contentDescriptionparameter toBpkSearchInputControl/BpkControlFieldImpl, so the field's accessible label can be set explicitly.clearAndSetSemanticson the control field'sBoxso TalkBack announces a single, explicit description instead of a merged one built from child nodes (prefix, value, placeholder).SearchInputControlStorydemo call sites with example descriptions.Test plan
SearchInputControlDockedStackrenders correctlycontentDescription