简体   繁体   中英

Adding web accessibility to twitter bootstrap accordion

I trying to add Keyboard Navigation to Twitter bootstrap accordion to enable web accessibility, Similar to http://hanshillen.github.io/jqtest/#goto_accordion .

I couldn't do the following:

  1. Once the focus is on Accordion Tabs, I couldn't just navigate accordion header. When I hit tab, it navigates the all inner links in the group, then to the next heading.
  2. I couldn't use up/down arrow keys
  3. After last accordion header tab thro', focus shifts outside the accordion.

Link to page

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Getting Started</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

</head>

<body>
<div class="row-fluid" id="main">
<div class="container">
  <div class="row-fluid">
    <div class="gutter10">
      <div class="row-fluid">
        <div class="span3" id="sidebar">
          <div class="selections">
            <h4 class="graydrkbg">Hello</h4>
          </div>
        </div>
        <!--sidebar-->
        <div class="span9" id="rightpanel">
            <div class="gutter10">
                <div class="accordion" id="accordion2">
                    <div class="accordion-group">
                        <div class="accordion-heading">
                            <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
                                Collapsible Group Item #1
                            </a>
                        </div>
                        <div id="collapseOne" class="accordion-body collapse in">
                            <div class="accordion-inner">
                                <p>
                                    <a href="http://en.wikipedia.org/wiki/Dogs" class="">More information about Dogs on Wikipedia</a>
                                </p>
                            </div>
                        </div>
                    </div>
                    <div class="accordion-group">
                        <div class="accordion-heading">
                            <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">
                                Collapsible Group Item #2
                            </a>
                        </div>
                        <div id="collapseTwo" class="accordion-body collapse">
                            <div class="accordion-inner">
                                <p>Anim pariatur cliche...</p>
                                <p>
                                    <a href="http://en.wikipedia.org/wiki/Dogs" class="">More information about Dogs on Wikipedia</a>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div><!--gutter10--> 
        </div><!--rightpanel--> 
      </div><!--row-fluid-->
    </div><!--gutter10-->
    <!--container--> 
</div><!--main--> 


<!--footer-->
<script src="../js/jquery-1.7.2.min.js" type="text/javascript"></script> 
<script src="../js/bootstrap.js" type="text/javascript"></script> 
</body>
</html>

So here is what I am going to do for lack of a better solution:

To .collapse I will add a display:none; This will hide it from sighted users as well as screen readers. Then to .in I'll add display:block; , which will make it visible to both again. So then, it skips the content in the tab order when closed, and adds it back when open.

so:

    .collapse {
       display:none;
    }

    .in{
       display:block;
    }

I haven't tested on screen reader yet, but I think it should work for down-arrow back into reading text. I'll update if not.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM