rangeFromLocator can return a collapsed range when text.highlight spans a paragraph boundary
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #813 by @phikaczu — closed without merging
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- html, swift
- Domain
- mobile-dev
Research direction
Start at rangeFromLocator and trace how it turns the Locator's text context into a range, especially when the highlight spans a paragraph boundary. Reproduce with the two-paragraph HTML fixture described in the issue, including the self-closing indexterm anchors. Done means the range is not collapsed and confirming the selection produces a visible highlight.
Written by the indexing model from the issue text.
Description
Describe the bug
When highlighting text in certain paragraphs of a commercial EPUB, the highlight commit path completes but no highlight renders visibly. The same gesture in adjacent paragraphs renders correctly. Visually, the failing paragraphs look like ordinary text paragraphs.
Expected: a visible highlight, matching the behavior in other paragraphs.
Observed: no visible highlight is rendered.
How to reproduce
The sample EPUB attached in this thread reproduces it: sample.epub.zip.
- Open the sample EPUB in a Readium-based reader.
- Long-press-drag a selection across the boundary between the two paragraphs.
- Confirm the highlight.
- Observe: no visible highlight is rendered.
The minimal failing structure is a two-paragraph fixture where the second paragraph opens with self-closing <a data-type="indexterm"/> anchors and repeats a noun phrase from the end of the first paragraph:
<p id="p-source">…"Uniform initialization" is an idea. "Braced initialization" is a syntactic construct.</p>
<p id="p-target"><a contenteditable="false" data-type="indexterm"></a><a contenteditable="false" data-type="indexterm"></a><a contenteditable="false" data-type="indexterm"></a>Braced initialization lets you express the formerly inexpressible.</p>
The selection that triggers the bug spans the paragraph boundary, producing this text context in the Locator:
locator.text = {
before: "…'Braced initialization' ",
highlight: "is a syntactic construct.\nBraced initialization lets you express",
after: " the formerly inexpressible."
};
The book where this was originally encountered is copyrighted (Effective Modern C++, O'Reilly) and cannot be attached. Additional samples can be tested if you'd like to provide them.
Readium version
3.9.0
OS version
iPadOS 26.5
Testing device
iPad Pro 11-inch (M4)
Environment
macOS: 26.5.1
platform: arm64
Xcode 26.5
Build version 17F42
Additional context
A few empirical patterns were observed while probing the failure:
- Extending or shrinking the selection by one or two words sometimes flips visibility.
- Selecting a single word within the affected paragraph (without crossing) renders visibly.
- Dominant language
- Swift
- Stars
- 557
- Forks
- 249
- Avg merge
- 3h 52m
- Merged PRs (30d)
- 19
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from readium/swift-toolkit
-
triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
readium/swift-toolkit#954 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
readium/swift-toolkit#841 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 57/100
readium/swift-toolkit#961 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
readium/swift-toolkit#959 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
readium/swift-toolkit#953 ·
Maintainers usually reply within 1 day
All issues in readium/swift-toolkit
Similar issues
-
area: models enhancement needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rexmhall09/TUFF#69 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nikitabobko/AeroSpace#2427 · 1 comment ·
Maintainers usually reply within 8 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
A second click on the Control Center widget doesn't close Control CenterPossibly taken @MaHofseth claimed this today. Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100