Switching text direction can sometimes swap the entire page's layout/direction if contenteditable element has focus
Categories
(Core :: DOM: Editor, defect, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox122 | --- | fixed |
People
(Reporter: itiel_yn8, Assigned: masayuki)
References
(Blocks 1 open bug)
Details
(Keywords: parity-chrome)
Attachments
(1 file)
STR:
- Open https://pontoon.mozilla.org/he/amo/all-resources/?extra=missing-without-unreviewed&string=66716, make sure you're signed in
- Focus the text box
- Ctrl + Shift + X (or right click on the textbox and select Switch Text Direction)
AR:
The page's layout changes instead of the textbox itself
ER:
Just the textbox direction changes.
This also happens on matrix chat (http://chat.mozilla.org/).
As per jfkthame (from #layout on matrix):
it looks like the flip-direction keyboard shortcut gets handled here:
https://searchfox.org/mozilla-central/rev/16526d690cccc9c60cacf09cc08e2c3041ef884e/editor/libeditor/EditorBase.cpp#5666-5692
and in the case of chat.mozilla.org, for example, it ends up setting the dir attribute on the <body> element
(rather than on something closer to the focused text area). I guess this has to do with how the page is structured.
reduced example:
data:text/html,<div>hello world</div><div style="width:50ch;border:1px solid gray" contenteditable>editable text</div><div>more text</div><input value="input element"><div>footer</div>
shift-ctrl-x in the input element flips only the input element; doing it in the contenteditable flips the entire page
Assignee | ||
Comment 1•1 year ago
|
||
Oh, looks like that EditorEventHandler
does not check whether the target is for its mEditorBase
. Therefore, both HTMLEditor
for the document and focused TextEditor
may handle the shortcut key.
Assignee | ||
Updated•1 year ago
|
Assignee | ||
Comment 2•1 year ago
|
||
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #1)
Oh, looks like that
EditorEventHandler
does not check whether the target is for itsmEditorBase
. Therefore, bothHTMLEditor
for the document and focusedTextEditor
may handle the shortcut key.
Oops, I misunderstood the report as Ctrl
+ Shift
shortcut key which is available only on Windows. Anyway, I'll keep taking a look.
Assignee | ||
Comment 3•1 year ago
|
||
Ah, this is just a web-compat issue.
Looks like that Chrome handles the command as a block format command. Therefore, closet block elements of each leaf node are updated by the feature. However, we always change the dir
attribute of <body>
if HTMLEditor
has focus.
It's hard to align the behavior to Chrome immediately. However, changing the dir
of <body>
is completely wrong if the editing host is a descendant of <body>
, i.e., it's not editable. So, for now, let's make HTMLEditor
toggle dir
of editing host.
Assignee | ||
Comment 4•1 year ago
|
||
Chrome handles text direction change as a block level format command. I.e.,
Chrome sets dir
attributes of enclosing editable blocks of selected leaf
nodes. However, aligning to this may require a lot of change and Thunderbird
may require the traditional behavior.
On the other hand, it's obviously wrong thing that Ctrl
+ Shift
+ X
in an
editable element changes the direction of entire the document since the <body>
may not be editable.
Therefore, this patch just changes the direction change target from <body>
to active editing host if it's an HTMLEditor
.
Comment 6•1 year ago
|
||
bugherder |
Description
•