Typing or autocorrecting inside a mention strips it to plain text
Les mainteneurs répondent en général sous 4 jours
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 70/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- ios, objective-c, react-native
Piste de recherche
Start in the iOS implementation of shouldChangeTextInRange:replacementText: and read MentionStyle.remove:withDirtyRange: plus handleExistingMentions; the issue identifies these paths and getMentionParamsAt: as relevant. Check how edits inside and at the edges of a mention affect its attributes and emitted HTML. Done means typing, autocorrecting, or backspacing cannot leave visible plain text with the mention id silently lost; verify both whole mention deletion and edits beside it.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Description
On iOS, any edit that lands inside a mention silently strips it to plain text. The name stays on screen, the <mention> tag disappears from the emitted HTML, and the id with it — so a reader still sees what looks like a mention, while the application has lost the person it pointed to. In a messaging app that means the mentioned user is never notified, and nothing on screen says so.
This is the same model as #691, which was reported and fixed for Android. That issue states the intended behaviour, and I agree with it:
it should either stay intact or be deleted as a whole atomically
That issue also says the problem is "not reproducible on iOS", where editing "removes the whole mention range instead of leaving orphaned plain text". Reading the current source, that does not seem to be the case: MentionStyle.remove:withDirtyRange: is commented // Strip meta only and calls removeAttribute:MentionAttributeName. The attribute goes; the characters stay.
Steps to reproduce
- In an
EnrichedTextInputwithmentionIndicators={['@']}, insert a mention withsetMention('@', '@Jane Doe', { id: '42' }). - Place the caret in the middle of the name and type one character — or let iOS autocorrect the name, which hits the same path.
- Read
onChangeHtml.
Expected: the mention is untouched (the character landing beside it), or it is removed whole.
Actual: <p>@Jane Dxoe</p> — plain text, no <mention>, no id.
A backspace inside the name does the same thing: one character disappears, and the mention silently stops being one.
Where it comes from
shouldChangeTextInRange:replacementText: consults no mention at any point, so every edit is accepted; handleExistingMentions then compares each mention's stored text to what the storage now holds, and drops the attribute when they differ.
Autocorrect is the worst case: it rewrites a proper noun without the user doing anything deliberate, and there is no way to opt out for a range — autoCorrect (added in 1.2.0, thanks!) is per-input, so turning it off to protect mentions also turns it off for the whole document.
Possible fix
Hold the rule where edits arrive, in shouldChangeTextInRange:replacementText::
- the modified range intersects a mention, and the replacement is empty → remove the whole mention (plus the space
setMentionappended) and returnNO; - it intersects a mention and the replacement is not empty → return
NO.
For a collapsed caret, only strictly inside should count — on either edge the character legitimately belongs beside the mention.
One detail worth noting for whoever implements it: -attribute:atIndex:longestEffectiveRange: fills the range even when the attribute is absent, so a zero-length range is not the signal it appears to be. getMentionParamsAt: returning nil is the reliable check.
I have this running as a local patch against 1.2.0 and I am happy to open a PR if the approach suits you.
Version
react-native-enriched-html 1.2.0, React Native 0.86.3, iOS.
- Langage dominant
- C
- Étoiles
- 1.4k
- Forks
- 76
- Merge moyen
- 3 j 10 h
- PR mergées (30 j)
- 23
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de software-mansion/react-native-enriched-html
-
[Feature request] Vertical spacing (margins) for headings and lists in htmlStylePeut-être pris @henrikra l’a pris il y a 19 jours. Ouverteenhancement
Difficulté 4/5 3-5 jours Accessibilité débutants 20/100
software-mansion/react-native-enriched-html#832 · 1 commentaire · 1 réaction ·
Les mainteneurs répondent en général sous 4 jours
-
[iOS] Tags not parsed on iOS below a certain string lengthPeut-être pris @hejsztynx l’a pris il y a 27 jours. Ouvertebug
Difficulté 4/5 3-5 jours Accessibilité débutants 42/100
software-mansion/react-native-enriched-html#811 · 3 commentaires ·
Les mainteneurs répondent en général sous 4 jours
-
[iOS, Android, Web] Return on an empty list item adds another item instead of ending the listOuvertebug
Difficulté 3/5 1-2 jours Accessibilité débutants 50/100
software-mansion/react-native-enriched-html#810 · 1 commentaire ·
Les mainteneurs répondent en général sous 4 jours
-
Support for `<raw-text-block>`Ouverteenhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
software-mansion/react-native-enriched-html#803 ·
Les mainteneurs répondent en général sous 4 jours
-
<img> wider than its rendering column fails to paint on Android — silently in isolation, with an "invalid measurement" error alongside any other text (not a decode-timing race)Peut-être pris @hejsztynx l’a pris il y a 47 jours. Ouvertebug
Difficulté 4/5 3-5 jours Accessibilité débutants 55/100
software-mansion/react-native-enriched-html#797 · 2 commentaires ·
Les mainteneurs répondent en général sous 4 jours
Toutes les issues de software-mansion/react-native-enriched-html
Issues similaires
-
bug game: 01008BA02525A000 ios
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
area/ysql kind/bug priority/medium status/awaiting-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
yugabyte/yugabyte-db#37523 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
Les mainteneurs répondent en général sous 3 jours
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 65/100
ly05010419/MacNativeGames#2079 ·
Les mainteneurs répondent en général sous 1 jour
-
severity: low
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
luainkernel/lunatik#2460 ·
Les mainteneurs répondent en général sous 1 jour