Text cursor (caret) disappears in Gmail compose window after inserting AI-generated text
Categories
(Core :: DOM: Editor, defect, P1)
Tracking
()
People
(Reporter: jrmuizel, Assigned: ltenenbaum)
References
()
Details
(Keywords: webcompat:platform-bug, webcompat:site-report, Whiteboard: [webcompat:sightline][webcompat:japan][webcompat:core], [wptsync upstream])
User Story
platform:windows,mac,linux,android impact:workflow-broken configuration:general affects:all branch:release user-impact-score:2400 diagnosis-team:dom
Attachments
(2 files)
Problem type: Something else
Description: Text cursor (caret) disappears in Gmail compose window after inserting AI-generated text ("Help me write" feature)
Steps to Reproduce:
Summary: Text cursor (caret) disappears in Gmail compose window after inserting AI-generated text ("Help me write" feature)
Steps to Reproduce:
Open Gmail web interface in Firefox (tested with a Google Workspace account that has the "Help me write" AI feature enabled).
Click "Compose" to open a new email.
Click the "Help me write" button (pencil/star icon) in the compose toolbar.
Enter a prompt and let the AI generate text.
Accept/insert the generated text into the email body.
Observe the compose text field.
Expected Behavior:
A blinking text cursor (caret) should be visible in the email body field after the AI-generated text is inserted, indicating the current input position.
Actual Behavior:
No blinking cursor is visible in the email body field. Clicking into the text field does not restore the cursor either. Typing still works — characters appear in the field — but there is no visible caret to indicate the current insertion point.
Notes:
The issue persists until the compose window is closed and a new one is opened.
Typing, selecting text, and other input actions still function correctly; only the visual cursor indicator is missing.
The issue does not occur in Microsoft Edge, suggesting it is Firefox-specific.
Browser Configuration
None
| Reporter | ||
Updated•17 days ago
|
| Reporter | ||
Comment 1•17 days ago
|
||
The cursor comes back for me when I refocus the window
| Reporter | ||
Updated•17 days ago
|
Updated•17 days ago
|
| Reporter | ||
Comment 2•17 days ago
|
||
I can reproduce this in the Mozilla gmail instance. Emilio, any suggestions for where to look about why the caret wouldn't be visible?
Comment 3•17 days ago
|
||
- Check if the editable thing still has focus (if you can type it probably does).
- Check whether we call
nsCaret::SetVisible(false)ornsCaret::AddForceHide(). Editor calls the later a couple times. - If that all seems to be fine I'd look at the display list code (around here)
| Reporter | ||
Comment 4•17 days ago
|
||
I see:
nsCaret::SetVisible(false)
* frame #0: 0x0000000113d04ce8 XUL`nsCaret::SetVisible(this=0x00000001217e12e0, aVisible=false) at nsCaret.cpp:142:27 [opt]
frame #1: 0x0000000113cbce40 XUL`mozilla::PresShell::SetCaretEnabled(this=<unavailable>, aInEnable=<unavailable>) at PresShell.cpp:2245:15 [opt] [inlined]
frame #2: 0x0000000113cbce0c XUL`non-virtual thunk to mozilla::PresShell::SetCaretEnabled() at PresShell.cpp:0 [opt]
frame #3: 0x0000000113ac6b60 XUL`mozilla::EditorBase::FinalizeSelection(this=0x000000012ff57000) at EditorBase.cpp:5944:58 [opt]
frame #4: 0x0000000113b186a0 XUL`mozilla::HTMLEditor::OnBlur(this=0x000000012ff57000, aEventTarget=0x0000000137c8ce40) at HTMLEditor.cpp:917:17 [opt]
frame #5: 0x0000000113ad5364 XUL`mozilla::EditorEventListener::Blur(this=0x000000012fc0c1c0, aBlurEvent=<unavailable>) at EditorEventListener.cpp:1179:48 [opt] [inlined]
but no corresponding nsCaret::SetVisible(true)
Comment 6•17 days ago
|
||
Hi Leo, you are also looking at some caret issues. Mind to taking a loot at this too? Thanks
| Assignee | ||
Comment 8•17 days ago
|
||
Hmm I think this has something to do with the fact that gmail sets contenteditable=false on the editor while the AI thing is active, and only sets it back to true a bit of time after it is refocused. But I can't reproduce this behavior in a smaller test case… I'll keep investigating :)
| Reporter | ||
Comment 9•17 days ago
|
||
Yeah, I saw the same thing
| Assignee | ||
Comment 10•17 days ago
|
||
Yes okay Document::EditingStateChanged can enable the caret (through MakeWindowEditable) but it returns early if the editing state doesn't change (and it looks like the editing state is always EditingState::eContentEditable if there is at least one contenteditable element on the page). So if a focused element becomes editable and there is any other editable element in the document then the caret is not enabled.
| Reporter | ||
Updated•17 days ago
|
| Reporter | ||
Comment 11•17 days ago
|
||
(In reply to Leo Tenenbaum [:ltenenbaum] from comment #10)
Created attachment 9570674 [details]
minimal example
Nice. Any idea how easy it is to fix?
| Assignee | ||
Comment 12•16 days ago
|
||
I think I have a working patch… But changing editor stuff is always risky so let's see what try thinks…
| Assignee | ||
Comment 13•16 days ago
|
||
Updated•16 days ago
|
Updated•16 days ago
|
| Reporter | ||
Comment 14•15 days ago
|
||
Leo, do you agree that Google should be able work around this by making the element contentEditable before focusing it?
| Reporter | ||
Updated•15 days ago
|
Comment 16•13 days ago
|
||
Comment 17•13 days ago
|
||
Comment 18•12 days ago
|
||
Backed out for causing caret related failures.
Failure logs:
- https://treeherder.mozilla.org/logviewer?job_id=561241408&repo=autoland&task=SZCe4W7lSLi_K-Y-wz-Fpw.0
- https://treeherder.mozilla.org/logviewer?job_id=561217765&repo=autoland&task=EQ79vMNlQiaHYnEqlPP_BQ.0
- https://treeherder.mozilla.org/logviewer?job_id=561249501&repo=autoland&task=DWuC_ox2RSqFgDiDR0gWpQ.0
| Assignee | ||
Comment 19•12 days ago
|
||
Hmm it looks like the problem is that we are no longer changing the selection when focusing a <textarea> for the first time. It looks like TextEditor::OnFocus doesn't update the document's selection because TextEditor uses its own selection controller (unlike HTMLEditor). I'm just trying to figure out what is the best way of fixing this…
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/59373 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Updated•10 days ago
|
Comment 22•5 days ago
|
||
Comment 23•5 days ago
|
||
Comment 24•5 days ago
•
|
||
Backed out for causing wr failures @nsINode.cpp.
- Backout link
- Push with failures
- Failure Log
- Failure Log ba @browser_text_selection.js
- Failure log @test_named_deck.html
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/59525 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
| Assignee | ||
Updated•4 days ago
|
Comment 27•2 days ago
|
||
Comment 28•2 days ago
|
||
| Assignee | ||
Comment 30•1 day ago
|
||
Ah, we no longer set selection to an <a> when it is focused. But we still use the old behavior if caret browsing is enabled, so it should be enough to enable it for that test.
Hopefully this is the last failure!
Description
•