Is there a way to dynamically change the text direction in a search field based on the language being typed by the user? For example, switch the direction to rtl
when typing in Arabic and to ltr
while typing in English.
I need to achieve this functionality while still being able to capture the selected value upon form submission. I tried using the dir
attribute on a div wrapping the select component, which worked but caused the selected value to be undefined. I also experimented with applying the direction
CSS rule to the select component, but it did not automatically change based on the typed language.
You can find the code for reference on this codesandbox link.