Add an ID to the CW spoiler input field to give aria-controls a handle on it. Pass that id to the CW trigger button. Modify text icon button component to accept aria controls id value. Add aria-expanded value to text icon button to indicate when it is expanded.
<div className='compose-form'>
<Collapsable isVisible={this.props.spoiler} fullHeight={50}>
<div className="spoiler-input">
- <input placeholder={intl.formatMessage(messages.spoiler_placeholder)} value={this.props.spoiler_text} onChange={this.handleChangeSpoilerText} onKeyDown={this.handleKeyDown} type="text" className="spoiler-input__input" />
+ <input placeholder={intl.formatMessage(messages.spoiler_placeholder)} value={this.props.spoiler_text} onChange={this.handleChangeSpoilerText} onKeyDown={this.handleKeyDown} type="text" className="spoiler-input__input" id='cw-spoiler-input'/>
</div>
</Collapsable>
}
render () {
- const { label, title, active } = this.props;
+ const { label, title, active, ariaControls } = this.props;
return (
- <button title={title} aria-label={title} className={`text-icon-button ${active ? 'active' : ''}`} onClick={this.handleClick}>
+ <button title={title} aria-label={title} className={`text-icon-button ${active ? 'active' : ''}`} aria-expanded={active} onClick={this.handleClick} aria-controls={ariaControls}>
{label}
</button>
);
label: PropTypes.string.isRequired,
title: PropTypes.string,
active: PropTypes.bool,
- onClick: PropTypes.func.isRequired
+ onClick: PropTypes.func.isRequired,
+ ariaControls: PropTypes.string
};
export default TextIconButton;
const mapStateToProps = (state, { intl }) => ({
label: 'CW',
title: intl.formatMessage(messages.title),
- active: state.getIn(['compose', 'spoiler'])
+ active: state.getIn(['compose', 'spoiler']),
+ ariaControls: 'cw-spoiler-input'
});
const mapDispatchToProps = dispatch => ({