Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #232 from smartive-education/feature/input-textare…
Browse files Browse the repository at this point in the history
…a-improvements

fix: input field and textarea needs unique id for label reference
  • Loading branch information
webrooster authored Mar 4, 2023
2 parents c7160c7 + 0f9a78b commit 19df964
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ interface IInteractionSvgStyles {
$count?: number;
}

const StyledCommentButton = styled.button(({ $count }: IInteractionButtonStyles) => [
const StyledCommentButton = styled.a(({ $count }: IInteractionButtonStyles) => [
tw`
font-semibold
leading-normal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useId, useState } from 'react';
import tw, { styled } from 'twin.macro';
import { Eye, Cancel } from '../icon/index';

Expand Down Expand Up @@ -30,6 +30,7 @@ export const InputForm: React.FC<IFormInputProps> = ({
onPressEnter,
}) => {
const [buttonType, setbuttonType] = useState(type);
const id = useId();

const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
setInputValue && setInputValue(e.target.value);
Expand All @@ -54,11 +55,11 @@ export const InputForm: React.FC<IFormInputProps> = ({
return (
<>
{editType === 'input' ? (
<FormLabel htmlFor={label} labelSize={labelSize}>
<FormLabel htmlFor={id} labelSize={labelSize}>
{label}
<FormInlineWrapperStyles>
<InputStyles
id={label.toLowerCase()}
id={id}
placeholder={placeholder}
type={buttonType}
required={required}
Expand All @@ -78,10 +79,10 @@ export const InputForm: React.FC<IFormInputProps> = ({
<FormFieldError>{errorMessage}</FormFieldError>
</FormLabel>
) : (
<FormLabel htmlFor={label} labelSize={labelSize}>
<FormLabel htmlFor={id} labelSize={labelSize}>
{label}
<TextArea
id={label}
id={id}
placeholder={placeholder}
required={required}
maxLength={500}
Expand Down

0 comments on commit 19df964

Please sign in to comment.