RTL
Hey,
There's a problem when my layout is html="rtl":
The input's placeholder defaults to ltr - span.algolia-autocomplete has style="direction:ltr".
I gather this bit from the source code is responsible:
getLanguageDirection: function getLanguageDirection() {
return (this.$input.css('direction') || 'ltr').toLowerCase();
}
If I specify style="direction:rtl!important" or dir="rtl", it properly aligns the placeholder, but it also stops auto-recognizing what direction the language that's typed in, so when I type in English and expect it to auto-jump to the left, it remains on the right side, resulting in the hint being unaligned with whatever's being typed in.

Any ideas how I can have the placeholder to be RTL to begin with, and keep the plugin auto-recognizing the typed in language direction?
(I need to support both LTR and RTL input, both when html dir="ltr" and html dir="rtl")
Arg, good catch. It has been a long time since I played with that feature but it indeed looks like a bug. I'll give it a try, in the meantime you can just pass the option hint: false to disable it.
This is still in your plans hopefully?
This is still in your plans hopefully?
Arg, didn't spend time on it yet but definitely something I need to investigate. I should be able to work on it this week. Sorry for the delay @legshooter :/
@legshooter If I am to investigate this issue, I would love to make sure we are doing it the correct way ;)
If I understand your previous statements correctly, you would like the autocomplete input direction:
- to equal the dir of the html by default
- be overridable at the autocomplete component level (e.g. use RTL even if html is in LTR)
Of course the hint should follow ;)
Please correct the wrong affirmations and complete the scenario if needed. I'd be glad to implement this ASAP. We have not been very accessibility friendly until now, and that is definitely something we want to address!
Yes, exactly what you described, but also:
When dir is auto, switching between LTR language and RTL language (left ALT + SHIFT on Windows) results in the cursor jumping to the left or to the right, respectively, and the hint follows. Which is great. I'd like to keep this behavior, even when the plugin detects that the document is in a certain explicit direction.
You might be wondering why - This is because the database can hold records in multiple languages, both RTL and LTR. So even if the document is in LTR, the user can decide to look for RTL records, focus on the search input, switch to an RTL language (ALT + SHIFT), and the curser + hint will be aligned properly to RTL (and vice versa), just like dir="auto" already does.
About the first part, which you covered, I tried changing:
getLanguageDirection: function getLanguageDirection() {
return (this.$input.css('direction') || 'ltr').toLowerCase();
},
to:
getLanguageDirection: function getLanguageDirection() {
return (this.$input.css('direction') || $('html').attr('dir') || 'ltr').toLowerCase();
},
Thinking this means: input dir overrides html dir overrides default hardcoded ltr. But for some reason, this.$input.css('direction') equals ltr no matter what, even though I don't set any dir on my input, and I can't find where it is being set first.
Thank you for the details. We will try to look into it ASAP.
Autocomplete v0 has been in low maintenance mode for a few years and we just released Autocomplete v1 so I'm closing this.
We'll properly come up with a plan to support RTL taking all the context from this thread. Thank you!
Resources