Unicode & Int’l SW‎ > ‎UTC‎ > ‎

bidi-dir

One issue that I'd like to raise is having more control over the bidi layout.

Here's the problem. It is typically the case that the direction of a text entry field, or other UI element, should depend on the contents. For example, when a user looking at a Hebrew page starts typing English in a field, you typically want to change the direction of the that field to LTR.

Currently we (Google) and other companies have to do this via Javascript. This is clumsy for a variety of reasons. To avoid this, and provide for more consistent capabilities across the web, we'd like to propose that the typical dir attributes in HTML be extended to add two new values. That is, instead of just having values {rtl, ltr} we also add:
  • auto-rtl: The first strong bidi character (according to the UBA) in the content of the element determines the direction. If there is no such character, the direction is rtl.
  • auto-ltr: The first strong bidi character (according to the UBA) in the content of the element determines the direction. If there is no such character, the direction is ltr.
The "first strong character" is the same condition used by the UBA (http://unicode.org/reports/tr9/#P2). While somewhat better results can be provided by more complicated heuristics, this would provide most of the support needed.

I raised the issue about the process for proposing such an extension to Ian Hickson and the W3C i18n group, and got the reply:

Interesting. I don't see any fundamental reason why we wouldn't want this feature.

I would recommend approaching browser vendors and seeing if they are willing to implement this extension. It may also require interaction with how CSS' 'direction' property works (since dir="" is defined in terms of 'direction' at this point).

Here's some recommended steps for how to go about adding this feature:
  http://wiki.whatwg.org/wiki/FAQ#Is_there_a_process_for_adding_new_features_to_the_spec.3F

Note: one question people might ask is:

> Why can't browsers just do this automatically anyway? Is there ever
> a need for a textbox to not do this?

Addison supplied an answer:

I'm not sure you would always *want* it to do that. Just because a string starts with an LTR character, for example, doesn't mean that the string's context should switch to LTR. We have examples in the bidi note that we just published that illustrate this. For example:

  <span dir="rtl">פעילות הבינאום, W3C</span>

That string should *start* displaying on the left with "W3C".

In some cases, text fields will look odd if they are auto directional. The text origin (where the characters come out of the cursor) is usually next to the text label, so:

    [     ltr text typing] : LEBAL

Looks more normal to me than:

    [ltr text typing     ] : LEBAL

If you typed some RTL, you'd see:

    [English CIBARA      ] : LEBAL

Instead of the more proper:

    [    CIBARA English ] : LEBAL

But there are use cases for allowing for auto-directionality too.
Comments