Skip to content

WIP: fix(ui): wrap long verse action labels without breaking bar alignment - #516

Draft
cameronapak wants to merge 1 commit into
mainfrom
fix/verse-action-label-wrap
Draft

cameronapak wants to merge 1 commit into
mainfrom
fix/verse-action-label-wrap

Conversation

@cameronapak

@cameronapak cameronapak commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

New here? Start here

What's this? Apps can add their own buttons to the verse action bar (the pill with highlight swatches, Copy, and Share that appears when a reader taps a verse) through verseActionItems. This PR makes long labels on those buttons wrap to two lines cleanly, instead of stretching one button across the bar.

Why does it matter? Apps pass labels in their own language, and some will be long, such as German compounds or descriptive actions. Today a long label widens its button, and at narrow widths it wraps anyway. When it wraps, the row stays vertically centered, so every other icon and the swatches drop out of line.

Who does it affect? End users of apps that pass custom verseActionItems. The default bar, which most apps show, looks the same.

What happens if we leave this as-is? Long custom labels keep producing very wide buttons. At narrow widths, such as a 320px phone, they keep misaligning the bar.

Before / after

All captures use the new Components/VerseActionPopover story with the worst-case labels (a German compound, Vietnamese, a long English action, and "Pin"), passed through actionItems. Each image shows main on top and this PR below.

Phone, 390px: scrolling the whole bar. Before, each label stays on one line, so the bar scrolls about 800px. After, long labels wrap to two lines, the strip scrolls about 460px, and every icon stays level. MP4 version

Before and after: scrolling the verse action bar at 390px

Desktop, 1298px. Before, the bar is 1188px wide and one button is 331px. After, the bar is 829px wide and the widest button is 128px.

Before and after: verse action bar at 1298px

Phone, 320px. Before, the long English label wraps on its own, and the centered row pushes every other icon and the swatches 8px down. After, the label is clamped to two lines and the icons stay level.

Before and after: verse action bar at 320px

RTL and dark mode, 390px, Arabic UI. After, the English label keeps its own direction, so the ellipsis sits at the end of the text.

Before and after: verse action bar in RTL dark mode at 390px

Default bar, 390px (no custom items, what most apps show). Unchanged.

Before and after: default verse action bar at 390px

What changed

  • Wrap and clamp. A label wraps to two balanced lines inside an 8rem cap. Longer text ends in an ellipsis. Custom actions get a title with the full label, and the accessible name already carries it.
  • Box hugs the text. CSS sizes a wrapped label's box to the cap, not to its longest line, which left the uneven gaps reported on feat(examples): build the web sample app from the Figma designs #514's first attempt. A layout effect measures the longest visible line and sets the label's width in em, so it holds under zoom and larger text. It re-measures when web fonts finish loading and does nothing without layout (jsdom).
  • Alignment. The row now top-aligns. The swatches and divider center on a one-line button (3rem) instead of on the row. A taller button grows downward, every icon stays on one line, and the swatches keep their default offset from the icons.
  • Smaller fixes found under worst-case data. Labels use dir="auto", so an English label in an RTL UI puts its ellipsis at the end. Buttons keep a 44px minimum width, matching the Swift SDK's minWidth: 44, so a label like "Pin" still gives a full-size target.

The Swift SDK (BibleReaderDrawer) never wraps: labels stay on one line in a horizontal scroll strip. This PR keeps that scroll strip and adds wrapping on web, where custom labels come from the host.

Verification

  • New story Components/VerseActionPopover with Default and LongCustomLabels. A data control switches between the default, demo, and worst-case label sets, all passed through actionItems. The worst case mixes a German compound, a Vietnamese label with stacked diacritics, a long English action, and "Pin".
  • LongCustomLabels has an integration play test. It checks that the long label is two lines, that its box is within 1px of its widest visible line, that all icons share one center, and that the swatches center on a one-line button. It fails on main ("expected 16 to be 32") and passes here.
  • Measured in Chromium at 1298px. Before: buttons up to 331px wide and a 1188px bar. After: the widest button is 128px and the bar is 829px. Every icon is at the same y, and the swatches keep the default 10px offset at 320px, 390px, 1298px, 200% zoom, a 200% root font size, RTL with Arabic, and dark mode. At 320px on main, the long label wrapped and pushed every other icon 8px down.
  • The default bar is unchanged in English. In Arabic, Copy grows from 38px to 44px because of the minimum width.
  • pnpm lint, the UI typecheck, all 681 UI unit tests, and 44 Storybook journeys pass (the new story, the verse action popover shadow stories, and the Bible reader and notes stories).

Not changed

  • At 390px or narrower, the default bar is about 8px wider than the viewport. The 100vw - 24px cap excludes the bar's px-4 padding, because only the custom-items mode sets box-border. This happens on main too.

Confidence Score: 4/5RetriggerView in Greptile

The PR appears safe to merge, with a non-blocking display issue for mixed-direction custom labels.

FindingsFix All in Claude Code

  1. P2 Mixed-direction labels shrink too far ▶
Fix with agent prompt
### Issue 1
packages/ui/src/components/verse-action-popover.tsx:226-232
`Range.getClientRects()` can return several text fragments for one line when a custom label mixes Arabic or Hebrew with Latin text. Taking the widest fragment makes `inlineSize` smaller than the complete line. Even a short label such as “حفظ في Notes” can then wrap unnecessarily or lose text to the two-line clamp.

Group fragments by their vertical position and measure each complete line before shrinking the label. Add a mixed-direction label to the story.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR caps action-button widths, wraps labels to two lines, and keeps icons and highlight colors aligned.

  • Long verse-action labels wrap without knocking the bar out of line.

Reviews (1) · Last reviewed commit: "fix(ui): wrap long verse action labels w..." · Reviewed by Greptile

A host's custom verse action label stayed on one line, so a long or
translated label widened its button. At narrow widths it wrapped anyway, and
the centered row then dropped every other icon and the swatches.

Labels now wrap to two balanced lines inside an 8rem cap, with an ellipsis
and a hover title for longer host text. The button measures its longest
visible line so it hugs the text and the gaps match one-line actions. The
row top-aligns, and the swatches and divider center on a one-line button,
so a taller button grows downward and the default bar is unchanged. Labels
take their own direction, and buttons keep a 44px minimum width.

A Storybook story renders the default, demo, and worst-case label sets.

Signed-off-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a2384a-252f-7574-8248-b01487dc3dd7
@changeset-bot

changeset-bot Bot commented Dec 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d3d66f1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@youversion/platform-react-ui Patch
vite-react Patch
@youversion/platform-core Patch
@youversion/platform-react-hooks Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines +226 to +232
const lines = Array.from(range.getClientRects())
.filter((line) => line.top < bottom)
.map((line) => line.width);
if (lines.length < 2) return;
const widest = (Math.max(...lines) * element.offsetWidth) / width;
const fontSize = Number.parseFloat(getComputedStyle(element).fontSize);
element.style.inlineSize = `${Math.ceil(widest) / fontSize}em`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Mixed-direction labels shrink too far

Range.getClientRects() can return several text fragments for one line when a custom label mixes Arabic or Hebrew with Latin text. Taking the widest fragment makes inlineSize smaller than the complete line. Even a short label such as “حفظ في Notes” can then wrap unnecessarily or lose text to the two-line clamp.

Group fragments by their vertical position and measure each complete line before shrinking the label. Add a mixed-direction label to the story.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/ui/src/components/verse-action-popover.tsx
Line: 226-232

Comment:
**Mixed-direction labels shrink too far**

`Range.getClientRects()` can return several text fragments for one line when a custom label mixes Arabic or Hebrew with Latin text. Taking the widest fragment makes `inlineSize` smaller than the complete line. Even a short label such as “حفظ في Notes” can then wrap unnecessarily or lose text to the two-line clamp.

Group fragments by their vertical position and measure each complete line before shrinking the label. Add a mixed-direction label to the story.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Cursor Fix in Codex

@cameronapak
cameronapak marked this pull request as draft December 3, 2026 17:19
@cameronapak cameronapak changed the title fix(ui): wrap long verse action labels without breaking bar alignment WIP: fix(ui): wrap long verse action labels without breaking bar alignment Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants