Skip to content

Commit

Permalink
add htmlFor to textfield and textarea (fix #230)
Browse files Browse the repository at this point in the history
  • Loading branch information
zemirco committed Jan 12, 2017
1 parent 30b558f commit 33db9b7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/js/textfield/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const TextfieldWrapper = ({
icon,
label,
value,
length
length,
htmlFor
}) => {
const isValueEmpty = value === undefined || value === ''
const isDefaultValueEmpty = defaultValue === undefined || defaultValue === ''
Expand All @@ -24,7 +25,7 @@ const TextfieldWrapper = ({
}
const showCounter = valueLength > length
return (
<label className={classnames('Textfield', {'Textfield--nolabel': !label})} >
<label className={classnames('Textfield', {'Textfield--nolabel': !label})} htmlFor={htmlFor}>
<div className='Textfield-icon-wrapper'>
{
icon
Expand Down Expand Up @@ -65,6 +66,7 @@ export const Textfield = ({float, error, length, ...rest}) => (
label={rest.label}
value={rest.value}
length={length}
htmlFor={rest.htmlFor}
>
<input
className={classnames('Textfield-input', {
Expand Down Expand Up @@ -138,11 +140,21 @@ export class Textarea extends React.Component {
resizable,
rows,
spellCheck,
value
value,
htmlFor
} = this.props

return (
<TextfieldWrapper defaultValue={defaultValue} error={error} float={float} icon={icon} label={label} value={value} length={length}>
<TextfieldWrapper
defaultValue={defaultValue}
error={error}
float={float}
icon={icon}
label={label}
value={value}
length={length}
htmlFor={htmlFor}
>
<textarea
autoFocus={autoFocus}
className={classnames('Textfield-input', {
Expand Down

1 comment on commit 33db9b7

@Fa-So
Copy link
Collaborator

@Fa-So Fa-So commented on 33db9b7 Jan 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.