简体   繁体   English

屏幕阅读器会读取所有内容,但不会对其进行制表

[英]Screen reader reads it all, but does not tab to it

So I have a react-redux e commerce app and I am having a problem figuring out how to get the screen reader to go from the payment section over to the order summary component that and read the order summary. 因此,我有一个react-redux电子商务应用程序,在解决如何使屏幕阅读器从付款部分转到订单摘要组件并读取订单摘要时遇到了问题。

Now if I click on the order summary contents which is a table, including the h4 header,the screen reader does read it, but I can't tab to it from the payment section. 现在,如果我单击包含表格的订单摘要内容(包括h4标头),则屏幕阅读器会读取它,但是我无法从付款部分中选择它。

This the OrderSummary.js file: 这是OrderSummary.js文件:

    <h2 className="title h3">Order Summary</h2>
              <table className="subtotal-wrapper body-color">
                <caption className="screen-reader-text">Order Summary</caption>
                <tbody>
                  <tr>
                    <th>Subtotal:</th>
                    <td>${formatPrice(this.props.orderSummary.originalSubtotal)}</td>
                  </tr>
                  {showShippingCost(this.props.orderSummary.totalShippingCost, this.props.orderSummary.totalShippingDiscount)}
                  <tr>
                    <th>Est Sales Tax:</th>
                    <td>${formatPrice(this.props.orderSummary.totalEstimatedTax)}</td>
                  </tr>
                  {getOptionalComponent('Total Savings:', this.props.orderSummary.discountedSubtotal)}
                </tbody>
              </table>

So when tabbing, ChromeVox and VoiceOver will go from this form in the Address.js component: 因此,在分页时,ChromeVox和VoiceOver将从Address.js组件中的以下表单中获取:

<form className="marketing-offer" onSubmit={doNothing} >
              <Checkbox
                name="marketingOptIn"
                checked={!!this.props.marketingOptIn}
                onChange={this.props.handleMarketingOptInChange}
              >
                <span className="payment-option special-offers">Yes! I would like to receive updates, special offers, and other information from shopDisney and The Walt Disney Family of Companies.</span>
              </Checkbox>
            </form>

straight to the order summary button of Continue to Review, completely skipping the table in OrderSummary.js . 直接转到Continue to Review的订单摘要按钮,完全跳过OrderSummary.js的表。

It does read it if I deliberately click on it, but it does not tab from the checkbox in the form field inside Address.js to OrderSummary.js as I would like. 如果我有意单击它,它的确会读取它,但是它并没有从Address.js内的表单字段中的复选框中OrderSummary.jsOrderSummary.js

How do I fix this? 我该如何解决?

尝试在要浏览的所有html元素上添加tabindex =“ 1”,tabindex =“ 2”等。

Setting tabindex="0" to the elements you want to be in the tab order will fix this. 将tabindex =“ 0”设置为要按Tab键顺序排列的元素将解决此问题。 tabindex="0" will add each element in the tab order based on the location in source code. tabindex =“ 0”将根据源代码中的位置按Tab键顺序添加每个元素。 By default only interactive elements are put into the tab order. 默认情况下,仅将交互式元素置于选项卡顺序中。

Although as a note, it is not recommended to add non-interactive elements into the tab order: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex#Accessibility_concerns 尽管需要注意,但不建议将非交互式元素添加到选项卡顺序中: https : //developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex#Accessibility_concerns

Using a tabindex of 0 instead of a positive number is great adivce, but as @CodyS mentions at the end of his post, putting non-interactive elements in the tab order is highly discouraged. 使用0而不是正数的tabindex是一个很好的选择,但是正如@CodyS在其文章结尾提到的那样,强烈建议不要将非交互式元素按Tab顺序排列。

If you are concerned that a screen reader user will not find the table or be able to read it, if your page is well organized, it shouldn't be a problem. 如果您担心屏幕阅读器用户将找不到该表或无法读取该表,并且您的页面井井有条,则不成问题。 And by "well organized", I mean sections are logically grouped with appropriate <nav> , <section> and other document structure elements, you have appropriate use of headings ( <h1> , <h2> , etc), and your tables are well formed ( <th scope="col"> ). 通过“井井有条”,我的意思是将各节按适当的<nav><section>和其他文档结构元素进行逻辑分组,并适当使用标题( <h1><h2>等),并且您的表格式良好( <th scope="col"> )。 Doing so means a screen reader user can use special navigation shortcut keys to find all these elements and get an overview of your page layout. 这样做意味着屏幕阅读器用户可以使用特殊的导航快捷键来查找所有这些元素并获得页面布局的概述。

Since you mentioned tables, make sure you have well defined column headers ( <th scope="col"> ) but also row headers ( <th scope="row"> ). 因为你提到的表,请确认你已经明确定义的列标题( <th scope="col"> 而且行标题( <th scope="row"> Row headers are often overlooked but they are tremendously helpful when navigating a table with a screen reader. 行标题通常被忽略,但是在使用屏幕阅读器浏览表格时,它们非常有用。 If I'm in a cell in the middle of the table and I navigate vertically down the column ( ctrl + alt + downarrow with a screen reader), then I will hear the cell value but might not know what the cell value is associated with. 如果我在表格中间的单元格中,并且垂直向下浏览列(使用屏幕阅读器按ctrl + alt + downarrow ),那么我会听到该单元格的值,但可能不知道该单元格的值与之相关。 If you have a row header, then the row header will be announced before the cell value is announced and it gives context to the cell. 如果您有行标题,则将在宣布单元格值之前宣布行标题,并为单元格提供上下文。 The first column in a table is often used as the row header, even if it just contains values. 表中的第一列通常用作行标题,即使它仅包含值也是如此。 Something like this: 像这样:

<table>
  <tr>
    <th scope="col">Name</th>
    <th scope="col">Age</th>
    <th scope="col">Favorite Color</th>
  </tr>
  <tr>
    <th scope="row">Jane</th>
    <td>35</td>
    <td>Red</td>
  </tr>
  <tr>
    <th scope="row">Mary</th>
    <td>36</td>
    <td>Blue</td>
  </tr>
  <tr>
    <th scope="row">Cindy</th>
    <td>37</td>
    <td>Green</td>
  </tr>
</table>

If my screen reader "focus" were on 35 and I moved down one cell, I'd hear "Mary 36" instead of just "36" and would know that 36 referred to Mary. 如果我的屏幕阅读器“焦点”位于35,而我下移了一个单元格,那么我会听到“玛丽36”而不是“ 36”,并且知道36是指玛丽。

When you talk about moving from the "payment" section to the "order summary" section, if those two sections litterally have a <section> element, then a screen reader user can navigate by landmarks and easily find the different sections. 当您谈论从“付款”部分移至“订单摘要”部分时,如果这两个部分在字面上都具有<section>元素,则屏幕阅读器用户可以按界标导航并轻松找到不同的部分。

<section aria-label="payment options">
  ...
</section>
<section aria-label="summary of order">
  ...
</section>

The aria-label will be read by the screen reader but is not visually displayed on the screen. aria-label将由屏幕阅读器读取,但不会在屏幕上直观显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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