Skip to content

Commit

Permalink
Improved form labels.
Browse files Browse the repository at this point in the history
See #109.
  • Loading branch information
boonebgorges committed May 1, 2018
1 parent 7e7530b commit 0bdb85a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
18 changes: 15 additions & 3 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37354,13 +37354,24 @@ class PreviewableField extends __WEBPACK_IMPORTED_MODULE_0_react__["Component"]
}));
}

const labelId = id + '-label';
const pfcLabel = '\u00a0';

return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(
'div',
{ className: contentSectionClass },
__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(
'label',
{ htmlFor: id },
label
{
htmlFor: id,
id: labelId
},
pfcLabel,
__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(
'span',
{ className: 'screen-reader-text' },
label
)
),
__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(
'div',
Expand All @@ -37379,6 +37390,7 @@ class PreviewableField extends __WEBPACK_IMPORTED_MODULE_0_react__["Component"]
)
),
__WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement('textarea', {
'aria-labelledby': labelId,
id: id,
name: id,
value: value,
Expand Down Expand Up @@ -38917,7 +38929,7 @@ class ResponseForm extends __WEBPACK_IMPORTED_MODULE_0_react__["Component"] {
}

// Non-breaking space.
const pfcLabel = '\u00a0';
const pfcLabel = 'Response text';

return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(
'div',
Expand Down
2 changes: 1 addition & 1 deletion build/index.js.map

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/components/PreviewableField.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,15 @@ export default class PreviewableField extends Component {
)
}

const labelId = id + '-label'
const pfcLabel = '\u00a0'

return (
<div className={contentSectionClass}>
<label htmlFor={id}>{label}</label>
<label
htmlFor={id}
id={labelId}
>{pfcLabel}<span className='screen-reader-text'>{label}</span></label>

<div className="edit-action-buttons">
{uploadElements}
Expand All @@ -83,12 +89,13 @@ export default class PreviewableField extends Component {
</div>

<textarea
aria-labelledby={labelId}
id={id}
name={id}
value={value}
disabled={isPending}
onChange={ e => {
onTextareaChange( e )
onTextareaChange( e )
} }
/>

Expand Down
2 changes: 1 addition & 1 deletion src/components/ResponseForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class ResponseForm extends Component {
}

// Non-breaking space.
const pfcLabel = '\u00a0'
const pfcLabel = 'Response text'

return (
<div className={divClassName}>
Expand Down

0 comments on commit 0bdb85a

Please sign in to comment.