Skip to content

Show the ABC branding grade only when the book has a level (BL-16775) - #8257

Draft
hatton wants to merge 1 commit into
masterfrom
BL-16775-grade-branding
Draft

Show the ABC branding grade only when the book has a level (BL-16775)#8257
hatton wants to merge 1 commit into
masterfrom
BL-16775-grade-branding

Conversation

@hatton

@hatton hatton commented Aug 28, 2026

Copy link
Copy Markdown
Member

Problem

In a collection that uses an ABC branding (ABC-BARMM and its siblings), every book showed a grade circle on the cover, the title page and the back cover, and the circle often showed the wrong grade. A book that had never been given a level showed "Grade 1". A book whose "This book is leveled" switch the user had just turned off went on showing the grade it had before, and kept it after a restart. The back cover, which is meant to read "Kindergarten" for a book with no level, showed a number instead.

Cause

The stylesheet drew the grade from data-leveledreaderlevel on the page body alone. The Leveled Reader tool keeps its level after the switch goes off, so that attribute outlived the level the book actually had. The server did not clear the number either: a substring test read leveled-reader-off as leveled-reader, and the routine that clears the number ran after the number had already gone out to the pages.

Fix

  • ABC-Reader-XMatter.less shows a grade only when the book has one. The grade rules now require the leveled-reader class, and the number and its "Grade " label appear only when the value is not empty. A book with no level gets an invisible circle, which is how it behaved before 2022.
  • The back-cover "Kindergarten" rule now names the class the ABC xmatter really emits (.backCoverRow), so it applies at all. It never did.
  • Book records the level and the stage on the body only while the book is of that kind, and writes them as soon as the user flips either switch.
  • BookData tests the body classes as whole words, and clears the number before the data goes out to the pages rather than after.
  • The Leveled Reader and Decodable Reader controls put the level, the stage, and the displayed number onto the page as the user changes them, so the circle follows the switch with no page change. Where a book is both kinds, the decodable stage wins, which is the order the server applies.

Ref: https://issues.bloomlibrary.org/youtrack/issue/BL-16775

Devin review


This change is Reviewable

In a collection with an ABC branding, every book showed a grade circle,
and the circle often showed the wrong grade. A book that had never been
given a level showed "Grade 1". A book whose "This book is leveled"
switch the user had just turned off went on showing its old grade. The
back cover, which should read "Kindergarten" for a book with no level,
showed a number instead.

The stylesheet drew the grade from data-leveledreaderlevel on the page
body alone. The Leveled Reader tool keeps its level after the switch
goes off, so the attribute outlived the level. The server did not clear
the number either: a substring test read "leveled-reader-off" as
"leveled-reader", and the routine that clears the number ran after the
number had already gone out to the pages.

ABC-Reader-XMatter.less now shows a grade only when the book has one.
The grade rules require the leveled-reader class, and the number and its
"Grade " label appear only when the value is not empty. The back-cover
"Kindergarten" rule now names the class the ABC xmatter really emits, so
it applies at all.

Book records the level and the stage on the body only while the book is
of that kind, and writes them as soon as the user flips either switch.
BookData tests the body classes as whole words, and clears the number
before the data goes out to the pages rather than after.

The Leveled Reader and Decodable Reader controls put the level, the
stage, and the displayed number onto the page as the user changes them,
so the circle follows the switch with no page change. Where a book is
both kinds, the decodable stage wins, which is what the server does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR prevents ABC-branded books without an active reader level or stage from displaying a stale grade and keeps reader state synchronized across the editor and persisted book DOM.

  • Gates ABC grade labels, numbers, colors, and circles on active reader state and fixes the back-cover Kindergarten selector.
  • Updates page and book body reader attributes immediately when switches, levels, or stages change.
  • Corrects whole-class matching and synchronization ordering for levelOrStageNumber.
  • Adds C# regression coverage for disabled and mixed reader states.

Important Files Changed

Filename Overview
src/BloomBrowserUI/bookEdit/toolbox/readers/ReaderToolSwitch.tsx Updates the editable page’s reader class and displayed number immediately when either reader switch changes.
src/BloomBrowserUI/bookEdit/toolbox/readers/readerToolPageState.ts Centralizes synchronization of reader attributes and the displayed level-or-stage value on the iframe body.
src/BloomBrowserUI/bookEdit/toolbox/readers/readerToolsModel.ts Refreshes page-level branding data whenever the selected reader level or stage changes.
src/BloomExe/Book/Book.cs Records level and stage body attributes only while their corresponding reader modes are active.
src/BloomExe/Book/BookData.cs Uses whole-word reader-class checks and corrects reader data before propagating the dataset through the document.
src/BloomExe/Edit/EditingModel.cs Reuses the active-reader-aware level calculation when correcting saved body attributes.
src/content/templates/xMatter/project-specific/ABC-Reader-XMatter/ABC-Reader-XMatter.less Hides grade presentation for empty reader values, fixes the Kindergarten selector, and scopes higher-grade overrides to active leveled readers.
src/BloomTests/Book/BookDataTests.cs Adds regression tests for clearing stale numbers and falling back to a decodable stage.
src/BloomTests/Book/BookTests.cs Verifies disabling leveled-reader mode clears the level recorded on the book body.

Reviews (1): Last reviewed commit: "Show the ABC branding grade only when th..." | Re-trigger Greptile

@hatton

hatton commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

[Claude Opus 5 from Hatton's machine during preflight] Consulted Devin on 2026-08-28 20:45 UTC up to commit 68b1c6753c.

It reported no bugs and one Investigate flag, about whether the leveled-reader class reaches bloom-player's page element. That flag is posted as its own thread, answered and resolved: bloom-player copies the book body's class attribute onto the page element. Devin found nothing else. One informational item: none.

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.

1 participant