Expose event.getTargetRanges() in oncompositionstart (and possibly oncompositionend as well)
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 202
- Forks
- 43
- PR merge metrics
- No merged PRs in 30d
Description
Problem: On Android-Chrome there's no way to capture initial composition target range (event.getTargetRanges()) when using dictation. There may be other situations like this.
Only compositionstart and compositionend are fired, no beforeinput, which I would need to determine selection (event.getTargetRanges) right before the composition started.
Reproduce:
- On a Samsung-Android phone, set cursor inside a word
- activate dictation (word gets underlined → this is the selection I'm after)
- stop dictation immediately (before making any voice inputs)
https://github.com/user-attachments/assets/7bbf1ad1-99d4-4906-afe8-edf400af6c96
Observations:
- as soon as dictation is enabled a
compositionstartevent is fired (now waiting for voice inputs) - if there are no voice inputs and the dictation is cancelled by the user, still a
compositionendevent is fired. Assuming that at the beginning the cursor was inside the word "hello"event.datawill have"hello"
Problem:
- at
compositionendthere's no way for me to set the selection to what should be replaced (the word that gets underlined initially) - in my editor this means i have to assume a collapsed selection (the cursor before dictation was enabled), which will insert the word from which the composition started again at the current cursor position.
Solution ideas:
- Expose
event.getTargetRangesin compositionstart event. Then i can capture the initial range that should be replaced (the word that has been underlined) - Change implementation so
event.datais""when nothing has been dictated - Only fire
compositionstartevent when something actually has been dictated.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the compositionstart and compositionend behavior described in issue #511, especially event.getTargetRanges() and event.data during Android Chrome dictation. Compare the three proposed solutions and determine which behavior the editing specification should define. Done means reaching agreement on the intended event API or behavior and documenting the resulting specification change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100