Skip to content

Commit

Permalink
option to make textarea input required or optional
Browse files Browse the repository at this point in the history
  • Loading branch information
antontranelis committed Nov 29, 2024
1 parent af639c7 commit 3014cf6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Components/Input/TextAreaInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type TextAreaProps = {
inputStyle?: string
defaultValue: string
placeholder?: string
required?: boolean
updateFormValue?: (value: string) => void
}

Expand All @@ -30,6 +31,7 @@ export function TextAreaInput({
inputStyle,
defaultValue,
placeholder,
required = true,
updateFormValue,
}: TextAreaProps) {
const ref = useRef<HTMLTextAreaElement>(null)
Expand Down Expand Up @@ -90,7 +92,7 @@ export function TextAreaInput({
</label>
) : null}
<textarea
required
required={required}
ref={ref}
value={inputValue}
name={dataField}
Expand Down
3 changes: 3 additions & 0 deletions src/Components/Profile/Subcomponents/ProfileTextForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ export const ProfileTextForm = ({
heading,
size,
hideInputLabel,
required,
}: {
state: FormState
setState: React.Dispatch<React.SetStateAction<any>>
dataField?: string
heading: string
size: string
hideInputLabel: boolean
required?: boolean
}) => {
const [field, setField] = useState<string>(dataField || 'text')

Expand Down Expand Up @@ -57,6 +59,7 @@ export const ProfileTextForm = ({
labelStyle={hideInputLabel ? 'tw-hidden' : ''}
containerStyle={size === 'full' ? 'tw-grow tw-h-full' : ''}
inputStyle={size === 'full' ? 'tw-h-full' : 'tw-h-24'}
required={required}
/>
</div>
)
Expand Down

0 comments on commit 3014cf6

Please sign in to comment.