Weird troubleshooting info for controlled inputs?
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 11.8k
- Fork
- 7.9k
- Merge medio
- 1g 11h
- PR unite (30g)
- 11
Descrizione
Hi team! 👋
During our translation work I came across a weird bit of troubleshooting advice on the <textarea> page.
Quite expectedly, it's also found in the <input> page.
It basically states that setting the controlling state variable to anything other than the raw e.target.value (e.g. transforming it to uppercase, used to illustrate the "bug", only it works just fine) is the cause for the caret jumping back to the beginning.
This seems misleading and borderline incorrect; one of the key benefits of controlled inputs is our ability to format / filter / validate values live (think phone numbers, SSNs, CC numbers, VAT identifiers, etc.) and this only moves the caret back when the resulting value is shorter. It doesn't reset it to the beginning.
Here's a CodeSandbox demonstrating things are just fine for many use-cases of setting the controlled value to a transformed version of the incoming DOM value.
Any light on this? What are the actually problematic patterns for caret jumping?
Best,
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia dalle sezioni collegate sulla risoluzione dei problemi nelle pagine di riferimento di React DOM input e textarea, quindi riproduci il comportamento nel CodeSandbox fornito. Confronta i valori controllati trasformati con lo scenario documentato dello spostamento del cursore. Il lavoro è completato quando la documentazione spiega accuratamente quali pattern di aggiornamento dei valori causano lo spostamento del cursore e non presenta più casi d’uso validi della formattazione come esempi fuorvianti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, react
- Ambito
- documentation
- Tipo di issue
- Documentazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100