[Android] Typing right after a mention with Samsung Keyboard removes the mention

Aperta
#878 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
android, react-native
Ambito
mobile-dev

Direzione di ricerca

Reproduce on the example app's test screen: Set Value with the <mention> markup, place the caret after Doe, and type x with Samsung Keyboard while watching the two onChangeHtml calls. Then trace the Android composing-text path (setComposingText) into detectActiveMention and setMention to see where the mention range is recomputed and stripped. Done means the edit emits <p><mention ...>@John Doe</mention>x</p> and an Android test covers the composing-word append case.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description

With Samsung Keyboard, the first character typed immediately after a mention (no space in between) lands inside the mention span, and the mention is then stripped. The tag and its attributes are gone even though the user never touched the mention text.

It happens with both the English and the Korean layout. It does not happen when the same character is sent without an IME (adb shell input text), so the editing logic on its own keeps the mention.

Steps to reproduce

Device: Galaxy Z Flip7, Android 16, Samsung Keyboard 5.9.30.97. Library: main at 23cc179d, example app.

  1. Open the example app and go to the test screen.
  2. Tap Set Value and submit:
    <html><p><mention text="@John Doe" indicator="@" data-id="1">@John Doe</mention></p></html>
    
  3. Tap the editor so the caret sits right after Doe.
  4. Type x on Samsung Keyboard.
Result

onChangeHtml fires twice for that one key press:

<p><mention text="@John Doe" indicator="@" data-id="1">@John Doex</mention></p>
<p>@John Doex</p>

Expected (this is also what adb shell input text x produces from the same state):

<p><mention text="@John Doe" indicator="@" data-id="1">@John Doe</mention>x</p>

The Korean layout behaves the same way with the first jamo: @John Doeㅇ shows up inside the mention, then the mention is removed.

Likely cause

I haven't confirmed this in a debugger. Samsung Keyboard seems to treat Doe plus the new character as a single composing word and rewrites the whole word through setComposingText. The mention span then covers the new character, its text stops matching the stored mention text, and detectActiveMention strips it as an edited mention.

This looks like the mention version of #734 / #737, which deal with inline styles when a predictive keyboard rewrites the composing word.

Notes
  • Where this shows up in practice: the user picks a mention, deletes the space setMention adds, and types a suffix. In Korean that is the normal way to write, because particles attach directly to a name.
  • Happy to open a PR once there is a direction you are comfortable with. One option is to keep the mention span on its original range when a composing replacement only appends after it.
Lingua principale
C
Stelle
1.4k
Fork
80
Merge medio
4g 19h
PR unite (30g)
21

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di software-mansion/react-native-enriched-html

Tutte le issue di software-mansion/react-native-enriched-html

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.