Repository navigation
Conversation
Checkbox states were keyed by their position in plainText, which has no image placeholders, but filtered by list ranges shifted by the number of preceding images. Every checkbox after an image lost or shifted its checked state. Key the states by the image-shifted position instead. Fixes software-mansion#819 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The localized correction matches existing position handling, leaves image-free documents unchanged, and has no identified blocking issues.
No open issues 🎉
What changed in this PR
Fixes #819 by preserving iOS checkbox states when inline images precede checkbox lists.
Changes:
- Includes preceding image placeholders when calculating checkbox-state positions.
- Documents why those positions must match image-shifted list ranges.
| File | Description |
|---|---|
ios/htmlParser/HtmlParser.mm |
Corrects checkbox-state offsets and explains the coordinate adjustment. |
Review effort: Balanced
hejsztynx
approved these changes
Oct 21, 2026
szydlovsky
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #819.
On iOS, when HTML has an inline image (
<img>) before checkbox lists, thecheckedstate of every checkbox item after the image is applied to the wrong position. The first item of each list after the image loses its state, and the others shift onto the item before them. The editor then emits HTML from this wrong state, so the next edit saves the lost states.Cause: in
HtmlParser.mm, an opening<li>inside a checkbox list stored its state atcheckboxStates[@(plainText.length)].plainTextdoesn't contain image placeholders yet. But the<ul>tag range is shifted by the preceding image count infinalizeTagEntry:to match the finalNSTextStorage, andprepareCheckboxListStyleValue:filters the states by that shifted range.InputHtmlParserandTextHtmlParserthen apply each key as an absoluteNSTextStorageposition. With N preceding images, every key was N positions too low.Fix: key the state by
plainText.length + precedingImageCount, the same image-shifted space the tag ranges and alignments already use. Links compensate for the same offset in the other direction, since they read back fromplainText.Impact: iOS HTML parsing only (
EnrichedTextInputandEnrichedText). Documents without images are unchanged, becauseprecedingImageCountis 0.Test Plan
EnrichedTextInputwith thisdefaultValue(all five items checked):onChangeHtmlkeeps only Dchecked. After: A is unchecked and B–E keepchecked.I verified this on the iOS 18.6 simulator (iPhone 16 Pro) in our app (react-native 0.86.2, Expo 57, new architecture). I applied this exact change to 1.1.1 with patch-package, and checked the loaded states and the emitted HTML after a checkbox toggle and after a text edit.
Not covered here: adjacent
<ul data-type="checkbox">lists with nothing between them render as one list (C joins D/E). That happens without images too, so it is separate from this bug.Screenshots / Videos
Before: A and D checked, B, C and E unchecked. After: A–E all checked. I can attach the simulator screenshots if useful.
Compatibility
Checklist
🤖 Generated with Claude Code