Live data from Hacker News

Add dir=“auto” to your inputs and textareas

mough.xyz

11–20 of 114 posts

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

#11
post #7

Sadly, both the website and the linked codepen render the source quite poorly. The period is in the wrong place! The rendered HTML is fine. I assume this is just the Unicode bidirectional algorithm failing, as it is wont to do. I imagine that a special cased algorithm that understood that HTML tags (the stuff between inclusive) should render as atomic things, internally LTR, but without imposing their direction on su…

The Unicode bidi algorithm isn't failing here, it's working as designed. The source code snippet has base direction LTR, but has mixed-direction content because of the Hebrew text. Punctuation marks have weak directionality, so the period shows up at the end of the RTL run. Since the base direction is LTR, the 'end' of the RTL run means the right side.

If you want to force mixed-direction content to render correctly, you often need to insert bidirectional control characters to specify where a certain directional run begins/ends. That doesn't make sense to add in this case, though, because it would mess up the rendering in the actual input example.

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

#12

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.

[deleted]

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

#15
Uh.

If I search for textarea and BiDi text, in pretty much all variations I can think of https://www.w3.org/International/talks/1602-oman is one of the top links.

And right in there, the "What if you don't know the direction in advance" section, https://www.w3.org/International/talks/1602-oman/#advance

I assume the problem is that the author doesn't really know the space, and so didn't even know that "BiDi" is the right search term here. (For "bi-directional text", since you don't want to specify a writing direction)

I don't even fault them for thinking "the results are wrong" - they aren't, if you search for RTL they're the right answer. But you won't know that until you know the space a bit better. This highlights a problem with relying on the Internet for answers - it doesn't know what you don't know. Sit down with anybody who's dealt with BiDi for a while, and one of their first questions will be "Do you mean RTL or BiDi"?

So, if you can, ask people, not software. Especially if you don't know the space.

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

#17

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.

I was under the same impression until a user of enso (a psychologist, not a dev) sent me a feature request with a code snippet.

I suspect he had some experience in reporting this category of bugs.

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

#18
post #4

Earlier quoted context omitted.

It works that way if you correctly use modern features of CSS/HTML. This is just one of those features. It’s very difficult to correctly update the web platform because backward compatibility is so important for the most widely used programming platform in the world.

Lol it's funny to summarize this discussion as: "we don't want to make a (seemingly) positive change because too many people rely on us to live in their 'backwards' ways".

Thats fine, but then you say "we're going to make a new html6, and if you put DOCTYPE html6 at the start of your page, then legacy behaviours like that will be dropped and we'll start doing the right thing by default"
Post reply on HN