Added id and aria-label values for input field component

no issue

- Adds `aria-label` on input fields and id for label's `for` to map to form control
- Fixes tests
This commit is contained in:
Rish 2020-04-27 14:08:07 +05:30
parent c53654d89b
commit eb4ed70303

View File

@ -27,18 +27,21 @@ const Styles = ({style = {}}) => {
};
};
function InputField({name, label, type, value, placeholder, onChange, style}) {
function InputField({name, id, label, type, value, placeholder, onChange, style}) {
const Style = Styles({style});
id = id || `input-${name}`;
return (
<>
<label htmlFor={name} style={Style.label}> {label} </label>
<label htmlFor={id} style={Style.label}> {label} </label>
<input
id={id}
type={type}
name={name}
placeholder={placeholder}
value={value}
onChange={e => onChange(e, name)}
style={Style.input}
aria-label={label}
/>
</>
);