where to add the aria-modal attribute?

若如初见. 提交于 2019-12-11 10:19:10

问题


So I have a project in React where the modal does not have the proper markup.

I know I need to have aria-modal="true", but I am not 100% sure if this attribute is added everywhere I have a className. So for example:

renderModal() {
    return (
      <Modal
        isOpen={this.props.isOpen}
        onRequestClose={this.toggleModal}
        contentLabel="Address Book"
        className={this.props.parentClassName ? 
            this.props.parentClassName + " address-modal" :
            "address-modal"}
        role="dialog"
      >
        {this.renderAddressForm()}
      </Modal>
    );
  }

  renderAddressForm(){
    return(
      <div className={this.props.parentClassName ? "form-"+this.props.parentClassName : null}>
        <h2 className="modal-title">{this.props.title}</h2>

Do I add aria-modal="true" in all the elements with a className? Such as <Modal>, <div>, <h2>?

I have read the documentation on ARIA 1.1 that says "The aria-modal attribute is used to indicate that the presence of a "modal" element precludes usage of other content on the page.", but I am not sure how to apply it.


回答1:


The aria-modal attribute goes on the same element as the role=dialog



来源:https://stackoverflow.com/questions/51600621/where-to-add-the-aria-modal-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!