【发布时间】:2018-01-04 19:21:18
【问题描述】:
WordPress 的 Gravity Forms 的单选按钮集有一个选项,称为“启用“其他”选项”。此选项添加嵌套在选项内的文本输入。
GF 的单选按钮一开始是个问题,因为它们没有字段集,但忽略这一点,这种其他选择会导致键盘可访问性问题。当您选择单选按钮组时,您很好,但是一旦您再次选择选项卡,焦点就会转到“其他”文本输入,您的单选按钮选择会更改为该选项,并且无法更改单选按钮返回到任何其他值。
这些怪物之一的代码是:
<li id='field_4_4' class='gfield gfield_contains_required field_sublabel_below field_description_below gfield_visibility_visible' >
<label class='gfield_label' >
Overall label that applies to all of the options
</label>
<div class='ginput_container ginput_container_radio'>
<ul class='gfield_radio' id='input_4_4'>
<li class='gchoice_4_4_0'>
<input name='input_4' type='radio' value='First option' id='choice_4_4_0' tabindex='14' />
<label for='choice_4_4_0' id='label_4_4_0'>
First option</label>
</li>
<li class='gchoice_4_4_1'>
<input name='input_4' type='radio' value='Second option' id='choice_4_4_1' tabindex='15' />
<label for='choice_4_4_1' id='label_4_4_1'>
Second option</label>
</li>
<li class='gchoice_4_4_2'>
<input name='input_4' type='radio' value='Third option' id='choice_4_4_2' tabindex='16' />
<label for='choice_4_4_2' id='label_4_4_2'>
Third option</label>
</li>
<li class='gchoice_4_4_3'>
<input name='input_4' type='radio' value='gf_other_choice' id='choice_4_4_3' tabindex='17' onfocus="jQuery(this).next('input').focus();" />
<input id='input_4_4_other' name='input_4_other' type='text' value='Other' aria-label='Other' onfocus='jQuery(this).prev("input")[0].click(); if(jQuery(this).val() == "Other") { jQuery(this).val(""); }' onblur='if(jQuery(this).val().replace(" ", "") == "") { jQuery(this).val("Other"); }' tabindex='17' />
</li>
</ul>
</div>
</li>
有没有办法让这个单选按钮组可以访问?我知道我可以取消选中“启用“其他”选项”并将“其他”创建为普通单选按钮,然后添加一个单独的文本输入作为条件字段来解决这个问题。问题是它在一个有多个编辑器的网站上添加和编辑表单,他们是非技术用户,有时可能会自己使用这个选项 - 所以我想找到一种方法让它工作,如果可能的话。
【问题讨论】:
-
现在我只想知道 HTML 标记的哪些部分需要更改以使整个键盘都可以访问。我会弄清楚如何欺负重力形式将其作为一项单独的任务吐出来。