[iOS] Checkbox checked state lost/misplaced after an inline image
Los mantenedores suelen responder en 5 días
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- objective-c, react-native
Línea de trabajo
Read ios/htmlParser/HtmlParser.mm, especially the checkbox state recording near line 477, list range adjustment near line 172, and prepareCheckboxListStyleValue. Compare how link ranges compensate for image offsets near line 759. Reproduce with the supplied HTML containing an image before checkbox lists; done means all checkbox states and list boundaries remain correct after loading and after toggling one item.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Before submitting a new issue
- I tested using the latest version of the library, as the bug might be already fixed. (1.1.1, the latest release; the code below is unchanged on
main@ 0d015a7b1d) - I tested using a supported version of react native.
- I checked for possible duplicate issues, with possible answers.
Bug summary
On iOS, when HTML contains an inline image (<img>) before checkbox lists, the checked state of the checkbox items after the image is applied to the wrong positions. Many items load unchecked, and some states land on a neighbouring item. Because the editor then emits HTML from this wrong state, the next edit anywhere in the document (even toggling one unrelated checkbox) saves the lost states. Checked items are silently unchecked.
Cause (from reading ios/htmlParser/HtmlParser.mm):
- When an
<li>opens inside a checkbox list, its state is recorded atcheckboxStates[@(plainText.length)](line ~477).plainTextdoes not contain the image placeholder characters. - The
<ul>tag range is shifted by+openImageCount(line ~172) to match the finalNSTextStorage, which does contain one placeholder per image. prepareCheckboxListStyleValuethen filterscheckboxStatesby that shifted range. So with N preceding images, every key is N positions too low. The first item of each list falls outside its list's range and is dropped, and the remaining states end up on the item before them.- Links already compensate for this (
adjustedRange.location - secondPassImageCount, line ~759), but checkbox states don't.
Suggested fix: record the state at plainText.length + precedingImageCount, or shift the keys by the same image offset when building the style value.
Library version
1.1.1
Environment info
react-native 0.86.2
expo 57.0.14 (dev client, new architecture)
react 19.2.3
iOS Simulator 18.6 (iPhone 16 Pro); also seen on a physical iPhone running iOS 26
Steps to reproduce
- On iOS, render an
EnrichedTextInputwith thisdefaultValue. All five items are checked:<html> <ul data-type="checkbox"> <li checked>A</li> </ul> <p><img src="https://placehold.co/200x120.png" width="200" height="120"/></p> <ul data-type="checkbox"> <li checked>B</li> </ul> <p>text</p> <ul data-type="checkbox"> <li checked>C</li> </ul> <ul data-type="checkbox"> <li checked>D</li> <li checked>E</li> </ul> </html> - Observed: A and D are checked; B, C and E are unchecked. Expected: A–E all checked.
- Tap A's checkbox to uncheck it. Observed in
onChangeHtml: only D remainschecked; B, C and E lost their state. Also, C's list was merged into the D/E list. Expected: B–E still checked. - The same HTML without the
<img>paragraph loads all five as checked. Android and web render it correctly.
Reproducible example repository
No standalone repo yet. The steps above use the stock component only, with no app code involved.
- Lenguaje dominante
- C
- Estrellas
- 1.4k
- Forks
- 69
- Merge medio
- 9 d 3 h
- PR fusionados (30 d)
- 7
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de software-mansion/react-native-enriched-html
-
Dificultad 2/5 Menos de una hora Aptitud para principiantes 73/100
software-mansion/react-native-enriched-html#826 ·
Los mantenedores suelen responder en 5 días
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
software-mansion/react-native-enriched-html#818 · 1 comentario ·
Los mantenedores suelen responder en 5 días
-
[iOS] Tags not parsed on iOS below a certain string lengthPosiblemente ocupada @hejsztynx la tomó hace 7 días. Abiertobug
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
software-mansion/react-native-enriched-html#811 · 3 comentarios ·
Los mantenedores suelen responder en 5 días
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 50/100
software-mansion/react-native-enriched-html#810 · 1 comentario ·
Los mantenedores suelen responder en 5 días
-
Support for `<raw-text-block>`Abiertoenhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
software-mansion/react-native-enriched-html#803 ·
Los mantenedores suelen responder en 5 días
Todos los issues de software-mansion/react-native-enriched-html
Issues similares
-
v9.6.0: CMake incorrectly enforces presence of libevdevPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Los mantenedores suelen responder en 1 día
-
[Bug] Unhandled ValueError terminates watchdog thread when GISRC value contains multiple colonsAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
bug Component component: net
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
RT-Thread/rt-thread#11913 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
contiki-ng/contiki-ng#3289 ·
Los mantenedores suelen responder en 3 días
-
area:docs help wanted type:enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día