Closed Bug 1845241 Opened 1 year ago Closed 9 months ago

[contenteditable] `RightClick` move caret at the start of the `contenteditable` element

Categories

(Core :: DOM: UI Events & Focus Handling, defect, P3)

Firefox 115
defect

Tracking

()

VERIFIED FIXED
121 Branch
Tracking Status
firefox-esr102 --- wontfix
firefox-esr115 --- wontfix
firefox115 --- wontfix
firefox116 --- wontfix
firefox117 --- wontfix
firefox118 --- wontfix
firefox119 --- wontfix
firefox120 --- wontfix
firefox121 --- verified

People

(Reporter: pomili.lorenzo85, Assigned: masayuki)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0

Steps to reproduce:

open the attached file and right click on the child div

Actual results:

the caret is moved at the start of the contenteditable element

Expected results:

the caret should be moved where the click happens, like when you use left click

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

Component: Untriaged → DOM: Editor
Product: Firefox → Core

#1 regression:

Good build: A caret appears at the right mouse click position.
Bad build: The caret is not shown.
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=06b2977afb85&tochange=569a45bfb71c

Suspect of #1 regression: ab8c0ebe600b7687cba76d7c2a429772ac9c0830 Graeme McCutcheon — Bug 682338 - Focus context menu's target on platforms where the context menu is shown on mousedown, not where it's shown on mouseup. r=enndeakin

#2 regression

The build from ae1dfa192faf: The caret is not shown as same as the above bad build.
Bad build: The caret is shown at the contenteditable element.
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=ae1dfa192faf&tochange=92c87e95915e

Suspect of #2 regression: 030d8d4684982327356a377cbb13c82b665ce992 Masayuki Nakano — Bug 1083629 Use nsHTMLEditor::IsAcceptableInputEvent() instead of nsEditor::IsDescendantOfEditorRoot() for checking if a mouse down event target is in focused HTML editor r=ehsan

Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: regression
Regressed by: 1083629, 682338

Other browsers seem to select the word that the user clicks on.

Severity: -- → S3
Flags: needinfo?(masayuki)
Priority: -- → P3

Well, it seems that the patch was written with wrong assumption.

On the other hand, I'm not sure that it's right behavior that caret is not moved with a right click in caret browsing mode. There is no handler for it, that was what I didn't expect.

Flags: needinfo?(masayuki)

Hmm, there was a request for making the old (and expected by the reporter here) behavior cancelable.

See Also: → 709476

Oh, and the old behavior may be triggered in unexpected cases too.

See Also: → 1648351

It seems that we can fix this with touching nsIFrame::HandleEvent. Taking a look...

Assignee: nobody → masayuki
Status: NEW → ASSIGNED
Component: DOM: Editor → DOM: Selection
OS: Unspecified → All
Hardware: Unspecified → All
Component: DOM: Selection → DOM: UI Events & Focus Handling

The patch will change Selection result so I don't think we should/can fix this in ESR branches.

The component has been changed since the backlog priority was decided, so we're resetting it.
For more information, please visit BugBot documentation.

Priority: P3 → --
Priority: -- → P3

FYI: Safari works similar to Chrome, but select a word under the cursor.

Hello,
just to be sure did you switch it to wontfix because you reschedule the fix?

I'm asking because with the current behvaior is not possible to understand where the user has clicked.
So in some cases is not possible to align the browsers behviors when you work on an WYSIWYG editor like TinyMCE

(In reply to pomili.lorenzo85 from comment #11)

Hello,
just to be sure did you switch it to wontfix because you reschedule the fix?
Hi, the bug is not resolved as wontfix. The current release and upcoming release is set to wontfix since we don't have a patch.
The bug is in the team's backlog.

ok, thanks for the clarification :)

The other browsers move focus and Selection whe right click even if the
clicked element is not editable and even if there is a non-collapsed selection.
Fortunately, we already have similar code for the middle button press.
Therefore, we can make it run when the pressed button is the secondary button.

This also fixes bug 416546 and does not resurrect bug 709476.

However, this patch adds 2 prefs for making users customizable. Our traditional
behavior is, we never collapse non-collapses selection with a right click even
if clicked outside the selection. This allows users to open context menu for
selected text much easier. Therefore, even though the behavior is different
from the others, we should keep the traditional behavior, but some users may
want the other browsers' behavior instead. For them, this should be switchable
by a pref.

Additionally, I'm still not sure collapsing selection with a right click in
non-editable content especially for users using the caret browsing mode.
Therefore, for making things safer, this adds a pref to disable the new behavior
in the non-editable content.

Pushed by masayuki@d-toybox.com:
https://hg.mozilla.org/integration/autoland/rev/81712ea02609
Make `nsIFrame::HandleEvent` move caret when secondary mouse button down r=edgar,emilio,dom-core
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/42439 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch
Upstream PR merged by moz-wptsync-bot
QA Whiteboard: [qa-120b-p2]

Reproducible on a 2023-10-08 Nightly build on macOS 12.
Verified as fixed on Firefox 120.0b5 and Nightly 121.0a1 on macOS 12, Windows 10, Ubuntu 22.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-120b-p2]
Blocks: 709476
See Also: 709476
Blocks: 1648351
See Also: 1648351
Regressions: 1864334
Target Milestone: 120 Branch → 121 Branch
Regressions: 1875690
No longer regressions: 1875690
Regressions: 1878273
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: