Skip to content

fix(ios): seed MO-active when a reader view registers - #230

Merged
ddfreiling merged 2 commits into
mainfrom
fix/ios-mo-active-on-reader-mount
Sep 16, 2026
Merged

ddfreiling merged 2 commits into
mainfrom
fix/ios-mo-active-on-reader-mount

Conversation

@ddfreiling

Copy link
Copy Markdown
Member

What & why

audioEnable enables media-overlay column-break prevention with:

self.currentReaderView?.setMOActive(true)

The call is optional-chained, so when no reader view is mounted at that moment the flag is silently dropped. A view that registers afterwards starts with isMOActive == false, and its per-resource check in navigator(_:locationDidChange:):

if shouldPreventColumnBreaks { injectColumnBreakCSS() }

never fires — shouldPreventColumnBreaks is isMOActive && preferences.preventMOColumnBreaks. So highlighted text can be split across CSS columns for the rest of the session.

Android has no equivalent gap: the flag lives on the singleton ReadiumReader, not on the widget, so a widget mounting later already sees it and re-injects on page change.

Changes

  • FlutterReadiumPlugin.registerAsCurrentReaderView seeds the incoming view's MO-active state from the live navigator (timebasedNavigator is FlutterMediaOverlayNavigator).
  • CHANGELOG entry under Unreleased / Fixed.

Verification

  • bin/format — clean.
  • bin/analyze — no issues in either package.
  • flutter build ios --no-codesign in flutter_readium/example — succeeded (Built build/ios/iphoneos/Runner.app), which is the gate flutter_readium/ios/CLAUDE.md requires for Swift changes.

Not verified: no runtime check of the highlighting itself. Reproducing the original symptom needs a guided-navigation or media-overlay book whose reader view mounts after audioEnable, which the current app flow does not normally produce — the deferral in the consuming app exists precisely to avoid that ordering. Android is untouched.

Context

Found while fixing Notalib/LYT4#1467. That app defers audioEnable for guided-navigation books until the reader reports ready, and the only thing that deferral buys is this ordering. With this fix the deferral becomes unnecessary and can be removed app-side.

🤖 Generated with Claude Code

ddfreiling and others added 2 commits September 16, 2026 23:18
`audioEnable` turns on media-overlay column-break prevention through
`currentReaderView?.setMOActive(true)`. The call is optional-chained, so when no
reader view is mounted yet the flag is simply dropped. A view that registers
afterwards starts with `isMOActive == false` and its per-resource
`injectColumnBreakCSS()` check never fires, so highlighted text can be split
across CSS columns for the rest of the session.

Seed the flag from the live navigator in `registerAsCurrentReaderView`. Android
has no equivalent gap: there the flag lives on the singleton `ReadiumReader`,
not on the widget, so a widget mounting later already sees it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ddfreiling

Copy link
Copy Markdown
Member Author

Necessary fix to get out, I take full responsibility and merge this.

@ddfreiling
ddfreiling merged commit fc9a15b into main Sep 16, 2026
14 checks passed
@ddfreiling
ddfreiling deleted the fix/ios-mo-active-on-reader-mount branch September 16, 2026 22:35
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