Live data from Hacker News

Add dir=“auto” to your inputs and textareas

mough.xyz

41–50 of 114 posts

Re: Add dir=“auto” to your inputs and textareas

#41

PSA: Assume dir="auto" if none provided in browsers you develop.

While that may be a saner default for user input form controls which are kind of a separate document, it would be a very bad default for every element. It is also probably not the best default if you know the user is inputing content in a specific language (but of course better than getting it wrong).

Re: Add dir=“auto” to your inputs and textareas

#43
post #34

Earlier quoted context omitted.

Instead of gatekeeping "the space" with insider abbreviations and belittling the author, you could appreciate that they raised awareness of the issue.

I am not "gatekeeping", I'm telling you that in spaces you don't know there's hidden complexity, and you shouldn't rely on the Internet. No amount of "awareness" is taking that away. Also, please tell me where I "belittled" the author.

It's a shame your post got downvoted. Sometimes I don't get the HN mob. I have no idea what groby_b is talking about

Re: Add dir=“auto” to your inputs and textareas

#44
Yeah, as far as I'm concerned, this is a deficiency of language detection. Specific types of input types should auto rtl based on the user agent's locale usage.

A number of other automatic behaviors exist simply when you change your primary language, and this is one of them that should change by default. You'll know this by experience if you speak another language and occasionally flip your primary language over. All the sites you browse start respecting your lang and locale settings.

Other technical or format-specific inputs should retain their relevant direction.

Re: Add dir=“auto” to your inputs and textareas

#45

Why in 2023 is this still an issue? Frameworks and browsers should be designed that if you totally ignore rtl support, the browser/framework just does some usable default. Just like if you don't set a font size, the browser chooses one for you. Or if you don't specify the background color, one is chosen for you.

It might totally make sense for user input controls to be a separate directionality context from the rest of the document by default.

But in general, i don't think there is a right answer that works in all cases. The existing defaults (bidi algorithm) do make a best guess that is probably the best guess possible.

Re: Add dir=“auto” to your inputs and textareas

#46
post #25

Why isn't this the default?

I imagine backwards compat is a big part, but also:

Dir=auto means ignore what came previously when trying to guess what direction this text is. Not setting a dir attribute means the browser should use the text in the parent/previous sibling element for figuring out what direction this element's text is. Auto might make sense as a default for a where user input is disconnected from the html, but would be a horrible default for most tags like

Re: Add dir=“auto” to your inputs and textareas

#47

Yeah, as far as I'm concerned, this is a deficiency of language detection. Specific types of input types should auto rtl based on the user agent's locale usage. A number of other automatic behaviors exist simply when you change your primary language, and this is one of them that should change by default. You'll know this by experience if you speak another language and occasionally flip your primary language over. All…

This is the correct solution. Updating every html form vs the source of a few browsers, no brainer.

In the meantime, browser plug-in?

Re: Add dir=“auto” to your inputs and textareas

#48
post #21
post #2

This is indeed an easy way to fix text rendering in your inputs and textareas. However, you'll also need to do the same for elements that render the submitted text. And once you encounter bidirectional text (e.g. an English product name within an Arabic paragraph), that opens up another whole can of worms... Note also that there's currently a regression in Chrome that affects how RTL text is rendered in inputs with d…

[flagged]

Adapting your UI to RTL localization is a much more difficult proposition, but what well-placed dir="auto" can do is prevent an LTR-language UI from falling apart in the face of RTL user data (looking at you Gmail).

Re: Add dir=“auto” to your inputs and textareas

#49
post #46
post #25

Why isn't this the default?

I imagine backwards compat is a big part, but also: Dir=auto means ignore what came previously when trying to guess what direction this text is. Not setting a dir attribute means the browser should use the text in the parent/previous sibling element for figuring out what direction this element's text is. Auto might make sense as a default for a where user input is disconnected from the html, but would be a horrible d…

That suggests making the top level (document as a whole?) have an implicit dir="auto". Alternately, the default dir="auto" is overridden by any parent with an explicit dir="..." setting.
Post reply on HN