refactor(android): replace pill chips with M3 scrollable tabs in inserter#512
Open
jkmassel wants to merge 2 commits into
Open
refactor(android): replace pill chips with M3 scrollable tabs in inserter#512jkmassel wants to merge 2 commits into
jkmassel wants to merge 2 commits into
Conversation
11 tasks
XCFramework BuildThis PR's XCFramework is available for testing. Add the following to your .package(url: "https://github.com/wordpress-mobile/GutenbergKit", branch: "pr-build/512")Built from 533e5e2 |
f12d97b to
0d42b4e
Compare
…rter Rebuilds the category strip on `SecondaryScrollableTabRow` + `Tab`. The platform component provides selectable-group semantics, horizontal scroll, auto-scroll-to-selected, ripple, `Role.Tab` a11y, the underline indicator + divider, and a 48dp touch target — all for free. Deletes the custom `CategoryChip`, its shared `MutableInteractionSource` ripple- clip trick, and the chip-design constants. `edgePadding` is set to `SEARCH_HORIZONTAL_PAD_DP - TAB_INTERNAL_TEXT_PAD_DP` so the first tab label's leading edge lines up with the search bar's outer left edge. M3 1.3.1 hardcodes `ScrollableTabRowMinimumTabWidth = 90.dp`. The `minTabWidth` parameter that would let us override it ships in 1.4.0 and isn't worth a project-wide Compose BOM bump for this PR. Also folds in a few targeted TalkBack semantics fixes elsewhere in the sheet, all introduced by #461: - Header title gets `heading()` for heading navigation. - Search field's `BasicTextField` gets a `contentDescription` matching its visible placeholder; the placeholder Text uses `clearAndSetSemantics {}` so it doesn't double-announce alongside the field. - Block tiles get `role = Role.Button` on their `clickable`. - Empty state gets `liveRegion = Polite` with a constant `contentDescription` ("No results") and `clearAndSetSemantics {}` on the visible Text, so TalkBack announces once on the empty-results transition rather than re-announcing on every keystroke. Blind users recover the query by focusing the search field (TalkBack reads back `editableText`).
0d42b4e to
ec3e135
Compare
The button was using `title={ __( 'Add block' ) }` on the
`@wordpress/components` `<Button>`, which only sets the HTML `title`
attribute (a hover tooltip on desktop). For an icon-only button,
TalkBack on Android either skips the node or announces something
unhelpful — the canonical accessible name comes from `aria-label`,
which `@wordpress/components` sets via the `label` prop, not `title`.
Switch to `label={ __( 'Add block' ) }` so the rendered HTML carries
`aria-label="Add block"` and TalkBack announces "Add block, button"
when focused. Empirically verified on a Pixel 9 Pro XL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related changes to the Android block inserter, all introduced by #461:
Rebuild the category strip on
SecondaryScrollableTabRow+Tab. Replaces the hand-rolled scrollable pill-chip row. The platform component provides selectable-group semantics, horizontal scroll, auto-scroll-to-selected, ripple,Role.Taba11y, the underline indicator + divider, and the 48dp touch target — all for free. CustomedgePaddingaligns the first tab label's leading edge with the search bar's outer left edge.Targeted TalkBack semantics fixes elsewhere in the sheet — header
heading(), search-fieldcontentDescriptionwith a cleared placeholder, block-tileRole.Button, empty-state live region with a stable announcement.Independent of #509 / #510 / #511.
Fix
1. M3 scrollable tabs
Deletes the custom
CategoryChip, its sharedMutableInteractionSourceripple-clip trick, and all the chip-design constants (CHIP_*,TOUCH_TARGET_MIN_DP,TABS_*_PAD_*).edgePadding = 4.dp(computed asSEARCH_HORIZONTAL_PAD_DP - TAB_INTERNAL_TEXT_PAD_DP) lines the first tab label's leading edge up with the search bar's outer left edge.containerColor = Transparentso the tab row blends with the bottom-sheet surface rather than rendering its own opaque container.M3 version note: M3 1.3.1 (pinned by Compose BOM 2024.12.01) hardcodes
ScrollableTabRowMinimumTabWidth = 90.dp. TheminTabWidthparameter that would let us override it ships in 1.4.0 and isn't worth a project-wide BOM bump for this PR — short labels like "Text" and "Media" render content-sized inside a 90dp slot.2. Other TalkBack semantics
heading()so TalkBack users can navigate by heading.BasicTextField) gets acontentDescriptionmatching its visible placeholder, and the placeholder Text usesclearAndSetSemantics {}so it doesn't double-announce alongside the field. TalkBack reads "Search blocks, edit box" empty; "Search blocks, edit box, " filled.role = Role.Buttonon theirclickableso TalkBack announces them as buttons.liveRegion = Politeso TalkBack announces the state change when search filters the grid down to zero. The visible Text still shows "No blocks match ''" for sighted users, but the live region'scontentDescriptionis the constant "No results" and the inner Text usesclearAndSetSemantics {}. TalkBack announces once on the empty-results transition rather than re-announcing on every keystroke. Blind users can recover the query by focusing the search field, which reads backeditableText.Touch-target audit also covered the close button and search-clear
IconButton— both already meet 48dp via M3'sminimumInteractiveComponentSize, which expands the layout-node bounds outside the user'sModifier.size.Test plan
./gradlew :Gutenberg:detekt :Gutenberg:assembleDebug :Gutenberg:testDebugUnitTestpasses.