fix(ui): collapse the BibleCard error state into one alert region - #321
Conversation
A failed passage request rendered two competing role="alert" regions: the "ERROR" label in the header slot and the icon plus status-aware sentence in the body. Screen readers announced both. The body block is now the only alert region. The header label keeps its place and its styling but drops role="alert" and aria-live. The body block drops its redundant aria-live and hides its icon with aria-hidden. No new i18n keys, and no change to how errors are derived. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A 404 means the passage is missing from the selected version, and switching versions is the fix. The picker was hidden whenever passageError was set, so the card offered no way out. The picker reads versionNum rather than the passage, so it renders and works while an error is showing. The header row needs no change: the "ERROR" label still sits on the left and the picker on the right. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: e719bbc The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
bmanquen
left a comment
There was a problem hiding this comment.
Review of this branch against the repo's documented standards and against what the PR body says it ships. Four inline comments below; two of them I'd call blocking.
Blocking
- The
aria-liveremoval inverse.tsxis a politeness change, not a de-duplication — it takesVerseOfTheDayand standaloneBibleTextViewfrom polite to assertive. The PR body and the changeset both call it "redundant"/"duplicate", and the source comment added in the same hunk says the opposite. - Turning on
showVersionPickerin theErrorstory makes anintegration-tagged story fire unmocked network requests.
Non-blocking
3. The changeset text needs the same correction as (1).
4. createError is duplicated verbatim across the two test files, and the new jsdom tests re-assert what the Error play function already covers — packages/ui/AGENTS.md prefers Storybook for UI component tests.
Separately, a scoping question, not a code finding. YPE-2360 is titled "React BibleCard error state needs better text", and this branch changes zero user-visible strings — packages/ui/src/lib/bible-text-error.ts and all six locale files are untouched. The PR body confirms this ("The text that they show does not change"), but doesn't record it as a deviation. Alert semantics and picker availability are both real fixes; if the wording work was deliberately split off, worth saying so here so the ticket doesn't look closed by this PR.
Everything the PR body claims about the implementation checks out otherwise: exactly one role="alert" renders during an error, the header ternary really does keep three branches, the picker renders and stays enabled while passageError is set, no new i18n keys, and changeset status confirms the single-package changeset bumps all three via the fixed group.
Keep aria-live="polite" on VerseUnavailableMessage. role="alert" implies assertive, so the attribute was an override, not a duplicate. Removing it would have moved VerseOfTheDay and standalone BibleTextView from polite to assertive announcements. Spread globalHandlers back into the Error story's msw handlers. A story-level handlers array replaces the preview-level one, so mounting the version picker sent the languages and versions requests to the live API. Extend the Error story's play function through the recovery path: switch to a version whose passage resolves and assert the alert clears. Drop the jsdom picker test that hand-mocked five BibleVersionPicker internals; the story covers it. Move createError into a shared test helper. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Delete packages/ui/src/test/errors.ts. bible-card.test.tsx called it once, so that call is now inlined. verse.test.tsx calls it nine times and keeps a local three-line helper, which is where it started. A shared module for one Object.assign was an abstraction ahead of a second real consumer. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The prior run's only job failed on the known dom-vapor timeout flake, and GitHub wedged the run record at in_progress so no re-run could be requested. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
YPE-2360 | Artifacts | Task
What problems was I solving
The
BibleCardcomponent shows an error state when a Bible passage does not load. This error state had two faults.Fault 1. A screen reader announced two alerts for one failure.
The card showed two separate regions with
role="alert". The first region was the word "ERROR" in the header slot. The second region was an icon plus a sentence that explains the error. Both regions were live regions. A screen reader therefore announced the word "Error" first, and then announced the sentence as a second alert.Fault 2. An error was a dead end.
The card hid the version picker when
passageErrorwas set. A 404 error means the passage is not in the selected Bible version. The fix is to select a different version. The card removed that control at the moment the reader needed it.After this change, a failed request announces one alert. That alert carries the sentence that explains the error. The reader can also select a different version without leaving the card.
What user-facing changes did I ship
role="alert"andaria-live, so a screen reader no longer announces it as a second alert. The version picker now shows during an error.aria-hidden, so a screen reader skips it. The block keepsrole="alert"andaria-live="polite". Both attributes are load bearing, and the section below explains why.VerseOfTheDayand standaloneBibleTextViewshow the same message block. Both components get the icon fix. Their announcement stays polite and their visible text does not change. Neither component gets an "ERROR" label, because that label belongs to theBibleCardheader slot.This change adds no new i18n keys. The eight status-aware messages, their six locales, and the code that derives errors are all unchanged. This PR does not rewrite the error copy. See "Scope: the copy work is a separate ticket" below.
How I implemented it
One alert region
In bible-card.tsx,
BibleCardHeaderErrorwas adivwithrole="alert"andaria-live="polite"around one<h2>. It is now the<h2>alone. Thedivheld no classes that changed the layout, so the card looks the same.The
<h2>uses the same classes asBibleCardHeaderReference. This reuse is deliberate. The card already puts an<h2>in that slot for the passage reference. The error label therefore adds no new heading level to the outline of the host page.In verse.tsx,
VerseUnavailableMessagekeepsrole="alert"and becomes the only alert region. It marks its iconaria-hidden. It also keepsaria-live="polite".That
aria-live="polite"is not redundant. In WAI-ARIA,role="alert"carries an implicitaria-live="assertive". An explicitaria-live="polite"on the same element overrides the implicit value downward. Deleting the attribute would therefore make the announcement assertive, which is a behavior change and not a cleanup.VerseOfTheDayrenders this block on page load, and an assertive announcement would interrupt whatever the screen reader is already saying. An earlier commit on this branch deleted the attribute; review caught it and it is restored.The header ternary keeps three branches instead of two. Two branches would fall through to the loading spinner during an error. The spinner would then turn forever.
The version picker during an error
In bible-card.tsx, the condition changed from
showVersionPicker && !passageErrortoshowVersionPicker. This is the whole source change. The picker readsversionNumand not the passage, so it works whilepassageErroris set.The header row needs no layout change. The word "ERROR" still sits on the left and the picker on the right. The class
yv:justify-betweenis still correct.Tests and the Storybook story
bible-card.test.tsx gets a new
BibleCard - Error stateblock with four tests:role="alert"region shows.<h2>that reads "Error".role="status"spinner shows during an error.The version picker is covered by the
Errorstory instead of by a fifth jsdom test. That jsdom test would have to hand-mock the five hooks thatBibleVersionPicker.Rootreads:useLanguages,useLanguage,useVersions,useFilteredVersions, anduseOrganizations. Those mocks couple this file to the internals of a component it does not test.packages/ui/CLAUDE.mdalso says to prefer Storybook for UI component tests.verse.test.tsx gets one test. One alert region shows. That region carries
aria-live="polite". The icon hasaria-hidden. The alert holds no "Error" text, because a standaloneBibleTextViewhas no header slot.Each test file builds its own error objects.
verse.test.tsxkeeps a local three-linecreateErrorand calls it nine times.bible-card.test.tsxneeds one error object, so it writes thatObject.assigninline.bible-card.stories.tsx gets
showVersionPicker: trueon theErrorstory. Itsplayfunction asserts one alert region,aria-live="polite"on that region, and an enabled picker. It then walks the whole recovery path: open the picker, search for the Amplified Bible, select it, and assert that the alert clears and the passage renders.That story also spreads
globalHandlersback into its ownmsw.handlersarray. A story-levelhandlersarray replaces the preview-level array instead of merging with it. Without the spread, the picker'suseLanguagesanduseVersionscalls fell through to the live API, silently, becauseonUnhandledRequestis'warn'. The 500 override is listed first, because MSW takes the first matching handler. Version 1588 (AMP) stays onglobalHandlersand still resolves, which is what makes the recovery path testable..changeset/biblecard-single-error-alert.md is a patch that names
@youversion/platform-react-ui.Deviations from the plan
The plan artifact is a structure outline, not a plan file. It changed twice during the work, so it already describes the final direction. The code and the outline now agree on every phase.
Implemented as planned
VerseUnavailableMessagekeepsrole="alert"and marks its iconaria-hidden. It also keepsaria-live="polite", which is a correction to the outline. See "Review feedback" below.BibleCardHeaderErroris now a bare<h2>with the classes ofBibleCardHeaderReference.&& !passageError.errorHeadingkey comes from the existing locale files.Deviations and surprises
/NIV/i. This test is stricter than the outline, and it does not conflict with it..changeset/config.jsonalready puts the three packages in afixedgroup, so a changeset that namesplatform-react-uialone still bumps all three.pnpm changeset statusshows this result. A changeset that names all three would also copy this UI-only text intopackages/core/CHANGELOG.mdandpackages/hooks/CHANGELOG.md. The three most recent UI fixes onmain(b592e72,9c2e8e4,9a2b3e9) each name only the package that changed. The outline records this deviation in its Phase 3 section.Scope: the copy work is a separate ticket
YPE-2360 asks for two things. It asks for clear error text, and it asks for a review of that text against Figma. This PR delivers neither. It fixes the alert semantics and the recovery path instead, and it changes no strings.
This split is deliberate, for two reasons.
main.Two claims in the ticket are already true in the code on
main, before this PR. The message block usesyv:text-foreground, not a red destructive token, so the state is not styled as an alarm. The library also already picks from eight status-aware messages inpackages/ui/src/lib/bible-text-error.ts, so a 404 and a 503 do not read the same. What is still open is whether those eight strings are the right strings.The follow-up ticket for the copy work is YPE-4856. It is linked to YPE-2360.
Review feedback
Commit
9ba2dc2responds to the review on this PR. Four changes:aria-live="polite"is restored onVerseUnavailableMessage. The earlier commit removed it as redundant. It is not redundant, becauserole="alert"impliesaria-live="assertive". The removal would have movedVerseOfTheDayand standaloneBibleTextViewfrom a polite announcement to an assertive one. The changeset, the doc comment, and this body all now say the same thing.Errorstory spreadsglobalHandlersback into itsmsw.handlersarray. Mounting the picker under the old array sent the languages and versions requests to the live API.Errorstory'splayfunction walks the recovery path end to end. It switches to a version whose passage resolves and asserts that the alert clears. Before this, the story asserted only that the picker was enabled, which is a weaker claim than the one the PR makes.createErrormoved intopackages/ui/src/test/errors.ts. Two test files declared the same helper. Commitd2abe0dreverses this one. Outsideverse.test.tsxthe shared module had exactly one caller, so it was an abstraction ahead of a second real consumer.verse.test.tsxkeeps the local helper it started with.bible-card.test.tsxinlines its single call. The file is deleted.Additions that are not in the plan
Doc comments above
BibleCardHeaderError, the header ternary, the version picker condition, andVerseUnavailableMessage. They put the reasoning of the outline into the source. They change no behavior.Items that were planned but not implemented
The jsdom test for the version picker during an error. The
Errorstory covers that behavior, and it covers it better, because the story renders the real picker instead of five mocked hooks.How the outline changed during the work
The outline changed shape twice. This history matters only if you read the artifacts next to the diff.
That reversal made two planned Phase 2 changes unnecessary. Both changes assumed an empty header slot. The header slot always has a child during an error. The
justify-endchange and the empty-row check therefore left the outline before Phase 2 started.How to verify it
Run these commands first:
Manual tests
Automated tests
pnpm typecheck pnpm lint pnpm test pnpm --filter @youversion/platform-react-ui test:integrationIf you use a fresh worktree, do these two steps before you run the commands above:
packages/core/.env.exampletopackages/core/.env.local. Without this file,YVP_API_HOSTis empty and all 16 core suites fail to collect. The core tests use MSW mocks, so placeholder values are enough. CI supplies both values as secrets.pnpm --filter @youversion/platform-react-ui build:css. Withoutdist/tailwind.css, twoWideContainerstories fail on the missingyv:card-contentcap. This failure is not related to this branch.Results on this branch, at commit
9ba2dc2:pnpm testpasses 1064 tests (core 369, hooks 289, ui 406).test:integrationpasses 451 tests across 39 files.pnpm typecheckandpnpm lintboth pass. Each count is one lower than the count before the review, which is the one removed jsdom picker test.Description for the changelog
Fix the
BibleCarderror state that announced two alerts instead of one, and keep the version picker usable during an error.Greptile Summary
The PR consolidates BibleCard failures into one polite alert while preserving the separate visual error heading and exposing the version picker as an in-card recovery path.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Reviews (4): Last reviewed commit: "chore: re-trigger the storybook test run" | Re-trigger Greptile
Context used: