# Dir="auto" for composer and elsewhere

**URL:** https://meta.discourse.org/t/dir-auto-for-composer-and-elsewhere/276330
**Category:** Feature
**Created:** [August 23, 2023, 4:12pm UTC](https://meta.discourse.org/t/dir-auto-for-composer-and-elsewhere/276330 "2023-08-23T16:12:31Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 23, 2023, 4:12pm UTC](https://meta.discourse.org/t/dir-auto-for-composer-and-elsewhere/276330/1 "2023-08-23T16:12:31Z")

</div>

Continuing the discussion from [What does the support mixed text direction setting do?](https://meta.discourse.org/t/what-does-the-support-mixed-text-direction-setting-do/91247):

> [@Supporting mixed text directions](https://meta.discourse.org/t/supporting-mixed-text-directions/91247/1):
>
> ### How does it work?
> 
> The setting only effects how content is displayed by the browser. It doesn’t affect content that is saved to the database. Text is parsed with a regular expression to determine it’s direction. The appropriate `dir` value is added to the text’s outer HTML tag. Ideally this same behaviour could be accomplished by setting the `dir` attribute to `auto`. This can’t be done yet, because `dir="auto"` is not supported by any IE browsers.

Should we deprecate this setting, composer button and add `dir="auto"` by default in our text areas? IE is not a blocker anymore.

> **[dir HTML global attribute - HTML | MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/dir)**
>
> The dir global attribute is an enumerated attribute that indicates the directionality of the element's text.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [August 23, 2023, 4:16pm UTC](https://meta.discourse.org/t/dir-auto-for-composer-and-elsewhere/276330/2 "2023-08-23T16:16:40Z")

</div>

This setting also affects non-textarea things. e.g. it is used to apply `dir=` to paragraphs/quotes in posts:

> <https://github.com/discourse/discourse/blob/c01a461ca8bc3a67f690c81d1e6a9c3bcf1c29ab/app/assets/javascripts/discourse/app/instance-initializers/post-decorations.js#L77-L81>

And topic titles:

> <https://github.com/discourse/discourse/blob/c01a461ca8bc3a67f690c81d1e6a9c3bcf1c29ab/app/assets/javascripts/discourse/app/models/post.js#L118-L118>

and more.

Can we use `dir="auto"` for all these things now? 🤞

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 23, 2023, 4:51pm UTC](https://meta.discourse.org/t/dir-auto-for-composer-and-elsewhere/276330/3 "2023-08-23T16:51:18Z")

</div>

Makes sense, users need this everywhere they input text:

- Composer textarea
- Composer preview
- Topic titles in topics
- Topic titles in lists
- Posts in topics
- Bio in usercard / profile
- Topic “previews” in topics lists

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [March 11, 2024, 4:53pm UTC](https://meta.discourse.org/t/dir-auto-for-composer-and-elsewhere/276330/4 "2024-03-11T16:53:22Z")

</div>

I took a stab at updating our `support_mixed_text_direction` setting to lean on `dir="auto"` instead of using a regex to parse all user input at render-time:

[https://github.com/discourse/discourse/pull/26129](https://github.com/discourse/discourse/pull/26129)

> [@Falco](#):
>
> composer button

I _think_ we’ll need to keep this. Setting `dir="auto"` on a textarea will use a heuristic to decide the direction of **the entire textarea**. That doesn’t sound too useful if you’re writing a post which contains a combination of rtl and ltr languages. So I think the button is required for you to switch back & forth while editing?

In cooked posts, the `dir="auto"` can be applied per-paragraph, which solves that problem.

Would be great if some readers / writers of RTL languages can weigh in on that, and perhaps take a look at the PR. (cc @osama - git suggests you have done a lot of work on our RTL logic)

---

<div class="post-metadata">

### Author: ![Osama](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osama/32/98013_2.png) [@Osama](https://meta.discourse.org/u/Osama)
#### Post date: [March 11, 2024, 10:30pm UTC](https://meta.discourse.org/t/dir-auto-for-composer-and-elsewhere/276330/5 "2024-03-11T22:30:55Z")

</div>

> [@david](#):
>
> I _think_ we’ll need to keep this. Setting `dir="auto"` on a textarea will use a heuristic to decide the direction of **the entire textarea**. That doesn’t sound too useful if you’re writing a post which contains a combination of rtl and ltr languages. So I think the button is required for you to switch back & forth while editing?

Yes, exactly, the button is very useful when you’re typing a post that mixes RTL and LTR languages.

Your PR LGTM @david 🚀

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [March 13, 2024, 9:29am UTC](https://meta.discourse.org/t/dir-auto-for-composer-and-elsewhere/276330/6 "2024-03-13T09:29:42Z")

</div>

This is now merged. Please let us know if you have any feedback

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [September 1, 2024, 7:00am UTC](https://meta.discourse.org/t/dir-auto-for-composer-and-elsewhere/276330/7 "2024-09-01T07:00:29Z")

</div>

This topic was automatically closed after 171 days. New replies are no longer allowed.
