Skip to content

fix(write): align a button or chip at the start of a line with the text margin (T-24) - #42

Merged
vlidholt merged 1 commit into
serverpod:mainfrom
LahiruHW:fix/t-24-button-line-start
Nov 4, 2026
Merged

vlidholt merged 1 commit into
serverpod:mainfrom
LahiruHW:fix/t-24-button-line-start

Conversation

@LahiruHW

@LahiruHW LahiruHW commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Wonky-Task: T-24
Wonky-Claim: 1EHS-TPEZ

Summary

A Wonky Markdown pill (button or chip) is painted 0.55 em left of its first character, into the widened space before it. At the start of a line there is no space before it, so the pill hung past the text margin. A left-to-right, start-aligned paragraph, heading or quote line whose text starts with a chip or button is now inset by that 0.55 em (leadingPillInset in inline_pills.dart, applied inside the quote bar and the numbered-heading badge, so those don't move). The pill painter now takes its em from the pill's text style, the same value the inset uses, instead of from the caret height, so the two always agree. In the browser the size is the same as before (the caret is 1.2 em there).

Spec updated: specs/wonky_write/11-wonky-markdown.md §7.2.

Known limit: a button that wraps onto the start of a later line in the middle of a paragraph still reaches 0.55 em past the margin. Indenting only that line would need a first-line indent, which Flutter text doesn't have.

Acceptance criteria

  • A button at the start of a line aligns with the text margin and doesn't overflow. The paragraph is inset by the pill's left padding, so the pill's left edge sits exactly on the margin. Tested for primary and secondary buttons and for chips.
  • Correct in light and dark. The fix is pure geometry and doesn't depend on colours. The widget tests run in both brightnesses, and I checked both by hand.
  • Undo and redo keep the layout. The inset comes from the view model, so it follows the document state. A widget test makes a link into a button, then undoes and redoes it, and checks the geometry after each step.
  • Normal text and other inline elements are unaffected. Only paragraphs whose first character is in a chip or button are inset. A test checks that a line with a button in the middle stays at the margin. Right-to-left, centred and right-aligned lines, list items and code blocks are unchanged.
  • Screenshots: light and dark, below.
image Light mode

image Dark mode

Test plan

  • dart analyze and dart format are clean
  • Tests of the changed packages pass (flutter test in wonky_write: 834 passed)
  • Specs updated (Write 11 §7.2)
  • New wonky_write/test/features/editor/components/inline_pills_test.dart. It records the pill painter's actual draw calls and compares the pill's left edge with the left edge of a plain line, for a button, a secondary button and a chip at the start of a line (light and dark), a button in the middle of a line, and button → undo → redo.
  • Checked by hand in a release build (/write/ on localhost:8082) in light and dark: a button and a chip at the start of a line, a button in the middle of a line, a button in a callout, and undo and redo.

🤖 Generated with Claude Code

…xt margin

A pill is painted 0.55 em left of its first character, into the widened
space before it. At the start of a line there is no space, so the pill
hung past the text margin. A left-to-right, start-aligned paragraph,
heading or quote line whose text starts with a chip or button is now
inset by that 0.55 em (inside the quote bar and the step badge). The
pill painter takes its em from the pill's text style, as the inset does,
instead of from the caret height.

Wonky-Task: T-24

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wonky-work-bot

wonky-work-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@wonky-work-bot

wonky-work-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

Wonky task review: T-24: Buttons at the start of a line is slightly off the page.

Screenshot: the description has an image of the changed UI.

The pull request perfectly addresses the layout bug by calculating an inset for lines starting with pills and adjusting the pill painter coordinates. The tests added are exceptionally thorough, verifying correct geometry across all edge cases including undo/redo. No unrelated changes were made, and specs were cleanly updated.

Acceptance criterion Verdict Evidence Note
A button placed at the start of a line aligns with the standard text margin and does not overflow off the page. Met wonky_write/lib/features/editor/components/inline_pills.dart (12-31), wonky_write/lib/features/editor/components/wonky_components.dart (820-824) The PR computes a leading pill inset when a line starts with a button and pads the text component accordingly.
The alignment is correct in both light and dark modes. Met wonky_write/test/features/editor/components/inline_pills_test.dart (55-90) The changes rely strictly on geometry instead of color, and widget tests pass in both brightnesses.
Undo and redo of inserting or modifying the button maintains the correct layout. Met wonky_write/test/features/editor/components/inline_pills_test.dart (114-158) The tests successfully cover undo/redo operations and verify that the margin geometry is maintained properly.
The fix does not affect the alignment of normal text or other inline elements. Met wonky_write/lib/features/editor/components/inline_pills.dart (14-28), wonky_write/lib/features/editor/components/wonky_components.dart (820-824) The padding is correctly constrained to apply exclusively to lines starting with a chip or button attribution.
The pull request description includes a screenshot of the changed UI (light and dark where both change). Met PR description The PR description contains both light and dark mode screenshots.

Scope:
No unrelated changes found.

Tests: Added. Excellent test coverage was added checking render box geometry for pills at start and middle of lines, as well as undo and redo.

Specs: Updated. Section 7.2 of the Wonky Markdown spec was properly updated to reflect the new inset and margin logic for pills.

Facts
  • Changed files: 4 (+219 −29)
  • Tests changed: yes
  • specs/ changed: yes
  • pubspec.yaml changed: no
  • Migrations added: none
  • Workflow or tooling changes: none
  • Security-sensitive paths: none

Reviewed commit ddb6112b9908. This review is advisory; CI and the maintainers decide.

@LahiruHW

LahiruHW commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@vlidholt
vlidholt merged commit 6563e69 into serverpod:main Nov 4, 2026
42 of 43 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants