Closed Bug 1951304 Opened 1 year ago Closed 8 days ago

Allow using double-tap to select text in input fields / text areas

Categories

(Core :: DOM: Selection, enhancement)

Firefox 156
enhancement

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
relnote-firefox --- 160+
firefox160 --- fixed

People

(Reporter: tippkaemper, Assigned: TYLin)

References

(Blocks 3 open bugs)

Details

(Keywords: webcompat:platform-bug)

User Story

user-impact-score:120

Attachments

(1 external file, 3 obsolete files)

Steps to reproduce:

(I can reproduce the problem on a Samsung Galaxy S25 and a Samsung Galaxy S22. I don't have any other Android devices available to test, so I don't know if this is Samsung specific.)

On an input field or text area on a website, double tap an existing word to select it.

Actual results:

The cursor jumps to the position of the double tap and a floating menu with "Paste" and "Select all" button appears

Expected results:

The double tapped word should be selected, the selection should be expandable by dragging the drop-shaped UI elements that mark the start and end of the selection, and the floating menu should have options for "Copy", "Cut", etc.

The Bugbug bot thinks this bug should belong to the 'Fenix::Browser Engine' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: General → Browser Engine

The severity field is not set for this bug.
:boek, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(jboek)

Not sure what the correct component is for this, if this isn't the right place could you please redirect it?

Component: Browser Engine → Panning and Zooming
Flags: needinfo?(jboek)
Product: Fenix → Core

I thought we had a "Layout: Text Selection" component for AccessibleCaret issues but maybe that's been folded into "DOM: Selection".

In any case: a specific URL that's affected would be helpful.

Component: Panning and Zooming → DOM: Selection

Hi Marius,

As Botond said, if you can provide a specific URL about where you experiences this, that'd be helpful!

Flags: needinfo?(tippkaemper)

Uuh, any URL works for me. E.g. www.google.com. Or the text area I'm using to type this very text.

Recorded a screen capture where I try to double tap text in the text field of the Google search website. In any other app this would select the word.

Flags: needinfo?(tippkaemper)

Sorry, that wasn't meant to sound impolite. :D
Thanks for looking into it, everybody.

The recording helped a lot..Yeah I am seeing the same thing, and I also expect the word to be focused.

I'll take a closer look. Thanks!

Severity: -- → S3
Flags: needinfo?(sefeng)

FWIW, I can't repro if I switch on Desktop mode on the device (I assume that's to be expected though)

(In reply to Marius Tippkämper from comment #0)

The double tapped word should be selected, the selection should be expandable by dragging the drop-shaped UI elements that mark the start and end of the selection, and the floating menu should have options for "Copy", "Cut", etc.

In case you're looking for a workaround, long-pressing a word in an input field has these effects.

Just to add one more piece of info: this does not seem to be a regression, at least not a recent one; Firefox for Android versions going back to at least 2020 behave this way.

Clear my NI given I won't be able to work on this

Flags: needinfo?(sefeng)

This doesn't work on Windows either.

OS: Android → All
User Story: (updated)
Assignee: nobody → soogbad
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

On Android, double-tapping text in a browser should select the word under
the tap, matching the behavior of native Android apps. Previously, Firefox
would instead show a paste/select-all menu without selecting a word.

This adds double-tap detection in GeckoView.dispatchTouchEvent (rather than
onTouchEvent, since the embedded SurfaceView consumes ACTION_DOWN before it
reaches onTouchEvent). On a detected double-tap, it dispatches a
GeckoView:SelectWordAt event with the raw screen coordinates to the
GeckoViewSelectionAction module, which forwards them via the
SelectionActionDelegate actor pair to SelectionActionDelegateChild in the
content process. There, windowUtils.selectAtPoint() with SELECT_WORDNOSPACE
selects the word at the converted client coordinates.

Hello guys, I submitted a revision for this :)

Component: DOM: Selection → General
Product: Core → Firefox for Android
Version: Firefox 135 → Firefox 156
Attachment #9629774 - Attachment is obsolete: true

Originally, Gecko can select a word by double click. Even if double tap by touch event, Gecko can fire double click event. But unfortunately, Accessible Caret eats some events, then double click isn't dispatched.

When 1st tap, Accessible Caret state is PressNoCaretState. then 2nd tap becomes PressCaretState. When 1st tap, we will set a selection as collapsed. It means that caret mode is Cursor. So Accessible Caret is shown as cursor mode. When 2nd tap, AccessibleCaretManager::PressCaret returns successful because caret is shown. Then state becomes PressCaretState. PressCaretState's event handlers return eConsumeNoDefault. So double click isn't dispatched.

So if caret isn't shown on 2nd tap, double tap can select a word.

This caret is shown by AccessibleCaretManager::OnSelectionChanged. So If we can delay calling AccessibleCaretManager::OnSelectionChanged() (APZ's double tap timer default value is 200ms), or calling AccessibleCaretManager::UpdateCarets() from AccessibleCaretManager::OnSelectionChanged() on each state, I guess that we will be able to fix this.

This caret is shown by AccessibleCaretManager::OnSelectionChanged. So If we can delay calling AccessibleCaretManager::OnSelectionChanged() (APZ's double tap timer default value is 200ms), or calling AccessibleCaretManager::UpdateCarets() from AccessibleCaretManager::OnSelectionChanged() on each state, I guess that we will be able to fix this.

"So If we can delay calling AccessibleCaretManager::OnSelectionChanged() (APZ's double tap timer default value is 200ms), or delay calling AccessibleCaretManager::UpdateCarets() from AccessibleCaretManager::OnSelectionChanged() on each state, I guess that we will be able to fix this." is correct.

hold on m_kato I actually just managed to get a working double tap to select build using the c++ approach. let me update the revision and you can read the code yourself and tell me if that's what you mean

On Android, double-tapping text in a browser should select the word under
the tap, matching the behavior of native Android apps. Previously, Firefox
would instead show a paste/select-all menu without selecting a word.

The root cause is that after the first tap places a cursor, the accessible
caret becomes visible. On the second tap, AccessibleCaretManager::PressCaret
succeeds (the caret is at the tap position), causing the ACE state machine to
enter PressCaretState, which returns eConsumeNoDefault for all events. This
prevents eMouseDoubleClick from being dispatched, so no word selection occurs.

Fix: in NoActionState::OnPress, detect when the incoming press is the second
tap of a double-tap (by comparing timing and position against the previous
press) and bypass PressCaret, instead transitioning directly to
PressNoCaretState (for touch events, preventing caret drag) or calling
SelectWordOrShortcut directly on the content PresShell (for APZ-synthesized
mouse events from the content process).

To support this, also:

  • Add DoubleTapState to AccessibleCaretEventHub for handling eMouseDoubleClick
  • Add TapType::eDoubleTapNoZoom and APZEventState::ProcessDoubleTapNoZoom to
    dispatch eMouseDoubleClick to content when double-tap zoom is not applicable
  • Wire eDoubleTapNoZoom through AsyncPanZoomController::OnDoubleTap /
    OnSecondTap -> ChromeProcessController -> BrowserChild -> APZEventState
Attachment #9629772 - Attachment is obsolete: true

i updated the revision. about your last two comments, copilot says:
Yes — our solution addresses exactly what the reviewer described, just through a different mechanism.

The reviewer's diagnosis:

1st tap → collapsed selection → OnSelectionChanged → UpdateCarets → caret becomes visible
2nd tap → PressCaret succeeds (caret is visible) → PressCaretState → eConsumeNoDefault → eMouseDoubleClick never dispatched
The reviewer's proposed fix: delay UpdateCarets by ~200ms so the caret isn't visible yet when the second tap arrives.

Our fix: detect the double-tap timing in NoActionState::OnPress and skip PressCaret when the second tap arrives within the window, regardless of whether the caret is visible. We skip PressCaretState for the same reason — preventing event consumption — but instead of hiding the caret, we recognize the double-tap directly.

The reviewer's delay approach is arguably simpler (no timing check needed), but has the downside that it would delay the caret appearing for every single tap by 200ms. Our approach is more targeted — it only activates on a detected double-tap without affecting single-tap caret latency.

actually i created a new revision for the c++ approach and closed the java revision

Attachment #9631992 - Attachment description: Bug 1951304 - Implement double-tap to select word in GeckoView. r=#geckoview-reviewers → Bug 1951304 - Implement double-tap to select word in Android

Back to DOM: Selection since this occurs on Windows (see comment #13)

Component: General → DOM: Selection
Product: Firefox for Android → Core

never had a problem with that on windows. might be a different problem that that specific user was having

I did look into this a while ago (llm assisted). This is not Android specific, it occurs on Windows as well if the device has touch input. I think this is APZ though, not DOM:Selection. (Sorry for playing ping-pong...)

Component: DOM: Selection → Panning and Zooming

i see, that makes sense

Severity: S3 → --
Type: defect → enhancement
Priority: -- → P3
Summary: Double tap to select text in input fields / text areas is not working → Allow using double-tap to select text in input fields / text areas
Assignee: soogbad → nobody
Status: ASSIGNED → NEW
Assignee: nobody → soogbad
Status: NEW → ASSIGNED
Component: Panning and Zooming → DOM: Selection
Status: ASSIGNED → NEW
Assignee: soogbad → nobody

(Removing priority flag to ensure the bug appears in the new component's triage dashboard.)

Priority: P3 → --
Assignee: nobody → soogbad
Status: NEW → ASSIGNED
Assignee: soogbad → nobody
Status: ASSIGNED → NEW
Assignee: nobody → soogbad
Status: NEW → ASSIGNED
See Also: → 1809060
Blocks: 2082580

Bug 1809060 comment 4 has an image of the touch area: CaretImage (red box) and
TextOverlay (blue box). Full is CaretImage + TextOverlay.

This patch changes the touch area for touch events to use CaretImage, making it
behave the same as mouse events. As a result, any touch interaction near the
cursor on the TextOverlay now works. For example:

  • double-tap to select a word
  • long-tap to select a word
  • single-tap to move the cursor

However, the trade-off is that dragging the caret by pressing the cursor or the
edge of the selection highlight stops working. Bug 2082580 tracks the work to
re-introduce it. This patch keeps the unused TouchArea::Full for the future
work.

Duplicate of this bug: 2077909
Duplicate of this bug: 1809060
See Also: 1809060 →
Assignee: soogbad → aethanyc
Attachment #9631992 - Attachment is obsolete: true

Makes sense. So you removed the TextOverlay dragging feature, which solves both problems, and now the new bug you opened about it will be left for if people would want to work on bringing it back in the future

Makes sense. So you removed the TextOverlay dragging feature, which solves both problems, and now the new bug you opened about it will be left for if people would want to work on bringing it back in the future

Exactly. Feel free to comment in bug 2082580 if you have any feedback.

Pushed by aethanyc@gmail.com: https://github.com/mozilla-firefox/firefox/commit/e1ccea708208 https://hg.mozilla.org/integration/autoland/rev/bc7a97109ee5 Use only CaretImage as the touch area for touch events. r=layout-reviewers,dshin
Status: ASSIGNED → RESOLVED
Closed: 8 days ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch

Did you want to nominate this for the Fx160 relnotes? If so, set the relnote-firefox flag to "?"
https://wiki.mozilla.org/Release_Management/Release_Notes_Nomination

Possible wording:

Fixed double-tapping a word in a text field on websites placing the cursor instead of selecting the word.

Flags: needinfo?(aethanyc)

Fixed double-tapping a word in a text field on websites placing the cursor instead of selecting the word.

The description is not accurate. I'll provide a wording below, but feel free to tweak it to meet the release note quality. Thanks!

Release Note Request (optional, but appreciated)
[Why is this notable]: It is a user perceivable fix that enables more touch actions near the cursor.
[Affects Firefox for Android]: Yes, and other desktop devices with touch events support.
[Suggested wording]: Fixed the touch actions near the cursor position in a text field, including double-tapping and long-tapping to select a word, and single-tapping to place the cursor.
[Links (documentation, blog post, etc)]: None.

relnote-firefox: --- → ?
Flags: needinfo?(aethanyc)

Thanks, added to the Fx160 nightly release notes, please allow 30 minutes for the site to update. This will carry over to the Fx160 beta release notes and eventually the Fx160 release notes.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: