Skip to content

feat(android): organize block inserter into cards with search#469

Merged
jkmassel merged 1 commit intojkmassel/android-block-pickerfrom
jkmassel/block-picker-organize
Apr 28, 2026
Merged

feat(android): organize block inserter into cards with search#469
jkmassel merged 1 commit intojkmassel/android-block-pickerfrom
jkmassel/block-picker-organize

Conversation

@jkmassel
Copy link
Copy Markdown
Contributor

@jkmassel jkmassel commented Apr 23, 2026

Stacks on top of #468. Organizes the native block inserter into iOS-parity per-section cards with a debounced search field and per-card Show More/Less, mirroring the iOS BlockInserterView. All UI is Jetpack Compose, hosted in a ComposeView inside GutenbergView's BottomSheetDialog so the integration surface is unchanged.

Changes

Layout

  • LazyColumn of rounded colorSurfaceContainerHigh section cards, each containing a chunked-Row grid of icon-over-label tiles. Span count is derived from display width with a min of 3 so narrow devices stay readable.
  • Tile = 44dp chip + 12sp caption (maxLines = 2, ellipsize end). Matches the iOS BlockInserterBlockView stack of BlockIconView over Text(title).lineLimit(2, reservesSpace: true).
  • Sections with a null name render headerless, matching iOS (gbk-most-used and gbk-contextual sit at the top with no label).
  • Sections with more than 16 blocks collapse with per-card Show More/Less — same threshold iOS uses.

Search

  • Debounced TextField at the top of the dialog. Ranking is a direct port of ios/Sources/GutenbergKit/Sources/Helpers/SearchEngine.swift (weighted title/name/keywords/description/category, prefix + Levenshtein fallback for short queries), so results order matches iOS.
  • Empty query restores browsable sections; zero-match query shows a No results empty state.

Compose

  • Library gains the org.jetbrains.kotlin.plugin.compose plugin and Compose BOM + ui + material3 deps (already declared in libs.versions.toml).
  • BlockInserterDialog keeps its existing BottomSheetDialog public surface; only the content is Compose.

Icon chip sizing and the contrast-aware tinting from #468 are unchanged.

Test plan

  • ./gradlew :Gutenberg:testDebugUnitTest :Gutenberg:detekt :Gutenberg:assembleDebug — BUILD SUCCESSFUL
  • Manually verified on Pixel 9 Pro XL with enableNativeBlockInserter on, dark theme: sections render, fuzzy search (imge → Image first), Show More/Less toggles in Theme section, swipe-to-dismiss, tile tap inserts block.
  • Reviewer: verify in light theme.
  • Reviewer: verify disabled blocks still render at 0.5 alpha and don't fire click handlers.

Related

@github-actions github-actions Bot added the [Type] Enhancement A suggestion for improvement. label Apr 23, 2026
@jkmassel jkmassel marked this pull request as draft April 23, 2026 20:43
@jkmassel jkmassel marked this pull request as draft April 23, 2026 20:43
@jkmassel jkmassel marked this pull request as draft April 23, 2026 20:43
@jkmassel jkmassel changed the title feat(android): render block inserter as an adaptive grid feat(android): organize block inserter into cards with search Apr 23, 2026
@jkmassel jkmassel force-pushed the jkmassel/block-picker-organize branch from 2287a41 to 20b6773 Compare April 23, 2026 22:04
@jkmassel jkmassel force-pushed the jkmassel/android-svg-icons branch from ae080ac to f19065a Compare April 24, 2026 16:51
@jkmassel jkmassel force-pushed the jkmassel/block-picker-organize branch from 20b6773 to f1afeab Compare April 24, 2026 17:57
@jkmassel jkmassel changed the base branch from jkmassel/android-svg-icons to jkmassel/android-block-picker April 24, 2026 17:57
@jkmassel jkmassel force-pushed the jkmassel/android-block-picker branch from 932e7ed to 9eaf0d5 Compare April 27, 2026 20:12
* refactor(js): extract native inserter pattern formatters

Pulls the inline pattern/pattern-category serialization in
`NativeBlockInserterButton` into named helpers in `src/utils/blocks.js`
and flips array fields (`blockTypes`, `categories`, `keywords`) from
`?? null` to `?? []` so the JSON shape matches the non-nullable
`List<String>` contract in the Kotlin `BlockPattern` model. Emitting
`null` for those fields would throw `SerializationException` on the
Android side.

* test(js): validate native inserter payload against JSON Schema

Adds `schemas/block-inserter-payload.schema.json` mirroring the Kotlin
`BlockInserterPayload` contract at
android/Gutenberg/src/main/java/org/wordpress/gutenberg/model/BlockInserter.kt,
plus `src/utils/blocks.test.js` which validates the output of
`preprocessBlockTypesForNativeInserter`, `formatPatternsForNativeInserter`,
and `formatPatternCategoriesForNativeInserter` against it via `ajv`.

The schema is draft-07 with `additionalProperties: false` on every
definition, and is co-located at the repo root so it can be consumed by
cross-language tooling (`quicktype`, `kotlinx-serialization` codegen)
alongside the hand-written Kotlin model. Upstream Gutenberg ships no
JSON Schema for these shapes (only JSDoc typedefs on
`WPEditorInserterItem` / `WPBlockType`), so the schema is hand-written
and tracks the Kotlin model as the source of truth.

Catches the null-vs-array drift that motivated #465, plus drift in
required fields, types, and unknown-field leaks that Kotlin's
`ignoreUnknownKeys = true` would otherwise silently tolerate.

Adds `ajv` as a direct devDependency (was transitive).
@jkmassel jkmassel force-pushed the jkmassel/block-picker-organize branch 2 times, most recently from 751d4ee to 7333438 Compare April 28, 2026 19:21
@jkmassel jkmassel force-pushed the jkmassel/block-picker-organize branch 2 times, most recently from 43be5d0 to bfc85d9 Compare April 28, 2026 19:43
@jkmassel jkmassel marked this pull request as ready for review April 28, 2026 19:50
@jkmassel jkmassel merged commit 1b33799 into jkmassel/android-block-picker Apr 28, 2026
22 checks passed
@jkmassel jkmassel deleted the jkmassel/block-picker-organize branch April 28, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant