Textarea: autodetect RTL
This commit is contained in:
parent
5bd1eab607
commit
3c2fef5a80
1 changed files with 5 additions and 0 deletions
|
@ -2,6 +2,9 @@ import clsx from 'clsx';
|
|||
import React, { useState } from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
|
||||
import { useLocale } from 'soapbox/hooks';
|
||||
import { getTextDirection } from 'soapbox/utils/rtl';
|
||||
|
||||
import Stack from '../stack/stack';
|
||||
import Text from '../text/text';
|
||||
|
||||
|
@ -52,6 +55,7 @@ const Textarea = React.forwardRef(({
|
|||
}: ITextarea, ref: React.ForwardedRef<HTMLTextAreaElement>) => {
|
||||
const length = value?.length || 0;
|
||||
const [rows, setRows] = useState<number>(autoGrow ? 1 : 4);
|
||||
const locale = useLocale();
|
||||
|
||||
const handleChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||
if (autoGrow) {
|
||||
|
@ -94,6 +98,7 @@ const Textarea = React.forwardRef(({
|
|||
'text-red-600 border-red-600': hasError,
|
||||
'resize-none': !isResizeable,
|
||||
})}
|
||||
dir={value?.length ? getTextDirection(value, { fallback: locale.direction }) : undefined}
|
||||
/>
|
||||
|
||||
{maxLength && (
|
||||
|
|
Loading…
Reference in a new issue