Live data from Hacker News

Add dir=“auto” to your inputs and textareas

mough.xyz

51–60 of 114 posts

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

#54
post #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,…

I would argue that it’s failing and working as designed.

Perhaps a syntax highlighter could learn to insert “first strong isolate” and “pop directional isolate” and to also enforce that content leaves the stack alone?

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

#55

Slightly related: I recently learned that vim has `:set rl` to make a text go from right to left. (`:set norl` to come back to regular)

Whoa that's pretty badass, and kind of fun trying to type that way even in English. I spent more time doing it than I should have

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

#56
post #8

There is also this shortcut of ctrl+shift+x to switch to RTL. Which is really funny when you do it on Twitter since it flips the entire user interface.

It's weirder even: Pressing ctrl-shift-x when the input field is highlighted inserts "rtl", then pressing it again flips the entire user interface but not the input field.

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

#57
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]

Just support English and eventually it won’t be a problem. Also put all your dates in UTC. Any other low hanging fruit we can knock out?
Post reply on HN