feat(android): organize block inserter into cards with search#469
Merged
jkmassel merged 1 commit intojkmassel/android-block-pickerfrom Apr 28, 2026
Merged
Conversation
2287a41 to
20b6773
Compare
ae080ac to
f19065a
Compare
4 tasks
20b6773 to
f1afeab
Compare
932e7ed to
9eaf0d5
Compare
* 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).
751d4ee to
7333438
Compare
This was referenced Apr 28, 2026
43be5d0 to
bfc85d9
Compare
3 tasks
2 tasks
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.
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 aComposeViewinsideGutenbergView'sBottomSheetDialogso the integration surface is unchanged.Changes
Layout
LazyColumnof roundedcolorSurfaceContainerHighsection cards, each containing a chunked-Rowgrid of icon-over-label tiles. Span count is derived from display width with a min of 3 so narrow devices stay readable.maxLines = 2, ellipsize end). Matches the iOSBlockInserterBlockViewstack ofBlockIconViewoverText(title).lineLimit(2, reservesSpace: true).namerender headerless, matching iOS (gbk-most-usedandgbk-contextualsit at the top with no label).Search
TextFieldat the top of the dialog. Ranking is a direct port ofios/Sources/GutenbergKit/Sources/Helpers/SearchEngine.swift(weighted title/name/keywords/description/category, prefix + Levenshtein fallback for short queries), so results order matches iOS.No resultsempty state.Compose
org.jetbrains.kotlin.plugin.composeplugin and Compose BOM + ui + material3 deps (already declared inlibs.versions.toml).BlockInserterDialogkeeps its existingBottomSheetDialogpublic 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 SUCCESSFULenableNativeBlockInserteron, dark theme: sections render, fuzzy search (imge→ Image first), Show More/Less toggles in Theme section, swipe-to-dismiss, tile tap inserts block.Related