Skip to content

Commit

Permalink
fix: add aria label to select element for content types (#7133)
Browse files Browse the repository at this point in the history

Co-authored-by: ediiotero <eddie.otero@oddball.io>
Co-authored-by: Mike Lumetta <mike.lumetta@adhocteam.us>
  • Loading branch information
3 people authored Mar 31, 2021
1 parent 3d20894 commit 4abbc62
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/core/components/content-type.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export default class ContentType extends React.Component {
contentTypes: PropTypes.oneOfType([ImPropTypes.list, ImPropTypes.set, ImPropTypes.seq]),
value: PropTypes.string,
onChange: PropTypes.func,
className: PropTypes.string
className: PropTypes.string,
ariaLabel: PropTypes.string
}

static defaultProps = {
Expand Down Expand Up @@ -40,14 +41,14 @@ export default class ContentType extends React.Component {
onChangeWrapper = e => this.props.onChange(e.target.value)

render() {
let { contentTypes, className, value } = this.props
let { contentTypes, className, value, ariaLabel } = this.props

if ( !contentTypes || !contentTypes.size )
return null

return (
<div className={ "content-type-wrapper " + ( className || "" ) }>
<select className="content-type" value={value || ""} onChange={this.onChangeWrapper} >
<select className="content-type" aria-label={ariaLabel} value={value || ""} onChange={this.onChangeWrapper} >
{ contentTypes.map( (val) => {
return <option key={ val } value={ val }>{ val }</option>
}).toArray()}
Expand Down
7 changes: 6 additions & 1 deletion src/core/components/param-body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ export default class ParamBody extends PureComponent {
}
<label htmlFor="">
<span>Parameter content type</span>
<ContentType value={ consumesValue } contentTypes={ consumes } onChange={onChangeConsumes} className="body-param-content-type" />
<ContentType
value={ consumesValue }
contentTypes={ consumes }
onChange={onChangeConsumes}
className="body-param-content-type"
ariaLabel="Parameter content type" />
</label>
</div>

Expand Down
3 changes: 2 additions & 1 deletion src/core/components/parameters/parameters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ export default class Parameters extends Component {
onChange={(value) => {
this.onChangeMediaType({ value, pathMethod })
}}
className="body-param-content-type" />
className="body-param-content-type"
ariaLabel="Request content type" />
</label>
</div>
<div className="opblock-description-wrapper">
Expand Down
1 change: 1 addition & 0 deletions src/core/components/response.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export default class Response extends React.Component {
: Seq()
}
onChange={this._onContentTypeChange}
ariaLabel="Media Type"
/>
{controlsAcceptHeader ? (
<small className="response-control-media-type__accept-message">
Expand Down
3 changes: 2 additions & 1 deletion src/core/components/responses.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ export default class Responses extends React.Component {
<ContentType value={producesValue}
onChange={this.onChangeProducesWrapper}
contentTypes={produces}
className="execute-content-type"/>
className="execute-content-type"
ariaLabel="Response content type" />
</label> }
</div>
<div className="responses-inner">
Expand Down

0 comments on commit 4abbc62

Please sign in to comment.