fix: add aria label to select element for content types (#7133)

Co-authored-by: ediiotero <eddie.otero@oddball.io>
Co-authored-by: Mike Lumetta <mike.lumetta@adhocteam.us>
This commit is contained in:
Giles Wells
2021-03-31 11:25:24 -04:00
committed by GitHub
parent 3d20894ce7
commit 4abbc62b87
5 changed files with 15 additions and 6 deletions

View File

@@ -11,7 +11,8 @@ export default class ContentType extends React.Component {
contentTypes: PropTypes.oneOfType([ImPropTypes.list, ImPropTypes.set, ImPropTypes.seq]), contentTypes: PropTypes.oneOfType([ImPropTypes.list, ImPropTypes.set, ImPropTypes.seq]),
value: PropTypes.string, value: PropTypes.string,
onChange: PropTypes.func, onChange: PropTypes.func,
className: PropTypes.string className: PropTypes.string,
ariaLabel: PropTypes.string
} }
static defaultProps = { static defaultProps = {
@@ -40,14 +41,14 @@ export default class ContentType extends React.Component {
onChangeWrapper = e => this.props.onChange(e.target.value) onChangeWrapper = e => this.props.onChange(e.target.value)
render() { render() {
let { contentTypes, className, value } = this.props let { contentTypes, className, value, ariaLabel } = this.props
if ( !contentTypes || !contentTypes.size ) if ( !contentTypes || !contentTypes.size )
return null return null
return ( return (
<div className={ "content-type-wrapper " + ( className || "" ) }> <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) => { { contentTypes.map( (val) => {
return <option key={ val } value={ val }>{ val }</option> return <option key={ val } value={ val }>{ val }</option>
}).toArray()} }).toArray()}

View File

@@ -133,7 +133,12 @@ export default class ParamBody extends PureComponent {
} }
<label htmlFor=""> <label htmlFor="">
<span>Parameter content type</span> <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> </label>
</div> </div>

View File

@@ -220,7 +220,8 @@ export default class Parameters extends Component {
onChange={(value) => { onChange={(value) => {
this.onChangeMediaType({ value, pathMethod }) this.onChangeMediaType({ value, pathMethod })
}} }}
className="body-param-content-type" /> className="body-param-content-type"
ariaLabel="Request content type" />
</label> </label>
</div> </div>
<div className="opblock-description-wrapper"> <div className="opblock-description-wrapper">

View File

@@ -197,6 +197,7 @@ export default class Response extends React.Component {
: Seq() : Seq()
} }
onChange={this._onContentTypeChange} onChange={this._onContentTypeChange}
ariaLabel="Media Type"
/> />
{controlsAcceptHeader ? ( {controlsAcceptHeader ? (
<small className="response-control-media-type__accept-message"> <small className="response-control-media-type__accept-message">

View File

@@ -95,7 +95,8 @@ export default class Responses extends React.Component {
<ContentType value={producesValue} <ContentType value={producesValue}
onChange={this.onChangeProducesWrapper} onChange={this.onChangeProducesWrapper}
contentTypes={produces} contentTypes={produces}
className="execute-content-type"/> className="execute-content-type"
ariaLabel="Response content type" />
</label> } </label> }
</div> </div>
<div className="responses-inner"> <div className="responses-inner">