New issue
Advanced search Search tips

Issue 660609 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: 2016-11-14
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

<div> doesn't support 'auto' direction per line.

Project Member Reported by samsmlee@google.com, Oct 29 2016

Issue description

What steps will reproduce the problem?
See https://jsfiddle.net/sr2ja8h8/ or alternatively follow instructions below.
(1) Have a <div> element with dir='auto'.
(2) In that <div> element, create a child <div> element with nothing set to its dir attribute.
(3) Have LTR language in the parent <div>
(4) Have RTL language in the child <div>.
(5) Notice that the first line "HELLO WORLD" is in LTR direction.
(6) The second line which is in a RTL language (Hebrew) is also LTR

What is the expected output?
I expected the second line to be in RTL direction.

What do you see instead?
The second line is in LTR direction.

It feels even more unexpected in a contentEditable element where you type English, press Enter, then type in Hebrew.
 

Comment 1 by samsmlee@google.com, Oct 29 2016

Labels: -Pri-2 Pri-3
Actually let me take this back, and file a different bug.

This bug will break too much stuff and is probably not a good way to fix this problem. :)

Comment 2 by samsmlee@google.com, Oct 29 2016

Summary: contentEditable <div> doesn't support 'auto' direction per line. (was: Should <div> child of a <div dir='auto'> parent inherit the parent's assigned direction, instead of the computed direction?)
Filed https://bugs.chromium.org/p/chromium/issues/detail?id=660619

Comment 3 by tkent@chromium.org, Oct 30 2016

Components: -Blink Blink>Editing

Comment 4 by yosin@chromium.org, Oct 31 2016

Components: -Blink>Editing Blink>Layout
Summary: <div> doesn't support 'auto' direction per line. (was: contentEditable <div> doesn't support 'auto' direction per line.)
Sample in #1 isn't editable. It seems editability doesn't affect this issue.

Comment 5 by yosin@chromium.org, Oct 31 2016

 Issue 660619  has been merged into this issue.

Comment 6 by kojii@chromium.org, Oct 31 2016

Cc: kojii@chromium.org
Labels: Needs-Feedback OS-All
I admit that I'm only 80% certain, but this looks like a by design to me. If you think I'm wrong, it'd be helpful to point me a link to spec that supports your expectations.

dir="auto" resolves to the first character, so LTR in this case. And since dir attribute inherits, the base direction of the 2nd div is still LTR.

From my best guess, what you want for your use case is probably not dir="auto", but "unicode-bidi: plaintext":
https://drafts.csswg.org/css-writing-modes-3/#valdef-unicode-bidi-plaintext

Remove dir="auto", and add this CSS (unicode-bidi does not inherit):
  div {
    unicode-bidi: -webkit-plaintext; /* WebKit does not support unprefixed yet */
    unicode-bidi: plaintext;
  }

But I recommend you to double-check the expected behavior with more bidi experts. dir=auto is designed this way intentionally, because that's what authors want in most cases. "unicode-bidi: plaintext" exists to support other, rarer use cases, and I can't determine which behavior is more appropriate for your use case from the description.

In most cases, the base direction is expected to be given explicitly. In case it is not easy, dir=auto gives so-so good heuristics. "unicode-bidi: plaintext" flips to a different heuristics logic for a specific case.

But explicit base direction is always most desired, and using "unicode-bidi: plaintext" will ignore it, so please use it in caution.
https://www.w3.org/International/articles/inline-bidi-markup/uba-basics#base_dir_scope

Comment 7 by kojii@chromium.org, Nov 2 2016

NextAction: 2016-11-14

Comment 8 by e...@chromium.org, Jan 4 2017

Status: WontFix (was: Untriaged)

Sign in to add a comment