Repository navigation
fix(android): align mixed nested list indents with iOS - #1023
Merged
Merged
Conversation
…apture mixed-list baselines Follow-up to the cherry-picked #1006 commit. `getBaselineMarkerWidth()` becomes `open val baselineMarkerWidth` to match `markerExtraWidth`, and `ListItemRenderer` restores `listItemMarkerWidth` through a `previousMarkerWidth` local like `previousMarkerExtra`. The five Android baselines are recaptured on the Pixel9-API36-EnrichedMarkdown AVD. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
3 of 6 tasks
1 of 6 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.
What/Why?
Supersedes #1006 by @mwolson, whose commit is carried over unchanged (17188be) with a small follow-up on top. We could not push to the fork branch, so this PR lands the same work from a repo branch.
Closes #1004.
On Android, a nested list whose marker type differs from its parent's gets the wrong space between marker and text. A numbered list under a bullet draws
1.over the first letters of its items (the repo's ownmixed_nested_list_testbaseline showed "1Django"), a task list under a bullet puts its checkboxes against the text, and bullets under a short1.sit far from their text. iOS already lays these out correctly.Nested items used a fixed
marginLeftas their text indent, so their text started from the parent's marker column while their marker was drawn from their own. Each nested item now starts its text from its own marker column, the way iOS does.The change is one term in
BaseListSpan.getLeadingMargin, next to themarkerExtraWidthfrom #1015. Each item records the column it reserves before any widening (baselineMarkerWidth), and its nested items get it asparentMarkerWidth. A nested item's margin is the difference between its own truncated absolute indent and its parent's, plus its own whole-pixel widening. The sum telescopes, so text lands atint(depth * marginLeft + column + gap)plus the ancestors' widenings at every depth, which is the iOSheadIndentformula, and the marker-to-text gap stays within a pixel ofgapWidth. Top-level lists and same-type nests with a whole-pixelmarginLeft(the default 24dp is 63 px on a Pixel 9) are unchanged. With a fractional pixelmarginLeft, same-type nests now alternate whole-pixel steps instead of always truncating, so their gap no longer drifts.Both Android renderers get the same change,
react-native-enriched-markdownand the standaloneenriched-markdown-android. In the React Native package the toggled copy of a task keepsparentMarkerWidth, so toggling leaves every indent where it was. iOS is not touched.Follow-up on top of #1006 (358aefc)
getBaselineMarkerWidth()is nowopen val baselineMarkerWidth, matching the siblingmarkerExtraWidth.ListItemRendererrestoreslistItemMarkerWidththrough apreviousMarkerWidthlocal, mirroringpreviousMarkerExtra.Pixel9-API36-EnrichedMarkdownAVD. The originals were captured on x86_64 Linux with software rendering and differed by anti-aliasing.Testing
ListRenderingTestin both Android packages gains the mixed-nest cases: all six parent and child combinations (tasks checked and unchecked), same-type and top-level geometry, absolute indents with fractional bullet sizes and margins, mixed ancestors followed by sibling lists, mixed nests in and around wide numbered lists, wrapped lines, RTL, and equalmarkerMinWidthcolumns. Six of them fail against the old formula in each package.TaskListInteractionTest: toggling a task under a bullet and under a number keeps every margin and drawn marker.testDebugUnitTestandktlintCheckpass (61 suites). React Native package: unit tests and ktlint pass (ListRenderingTest 18/18, TaskListInteractionTest 3/3).mixed_nested_list_markers_test(bullets and numbers both ways, and task lists),mixed_nested_list_test(React Native and native Android examples) andlist_sublist_first_combo_testall pass and their five baselines are refreshed from this AVD.mixed_nested_list_testscrolls once on Android before its capture so the last rows are not under the gesture bar.Screenshots
From #1006, React Native example on Android (
mixed_nested_list_testandmixed_nested_list_markers_test), with iOS for reference:PR Checklist
🤖 Generated with Claude Code