wpaccessibility / settings-api-enhanced

An improved WordPress Settings API with default render callbacks and a new accessible layout.
9 stars 0 forks source link

Figure out proper way to handle radio groups with a custom text element #40

Open felixarntz opened 7 years ago

felixarntz commented 7 years ago

As previously discussed in #38, we need to figure out a good way to handle radio groups with a custom text element.

There are currently three cases in core settings:

What makes this even more complex is that all three fields contain an additional component: some kind of example (date format / time format / URL structure respectively). In the case of the Permalink Structure field, the example is even combined with the text field.

Let's think about how we can create clean markup for these fields which is accessible and at the same time visually clear.

hedgefield commented 7 years ago

I'm not that familiar with how wordpress works code-wise, but one thing I noticed is that the custom input field is technically using two radio buttons, one for the explanation and one for the input. Could this be simplified to something like?:

<span class="radio-item">
<input type="radio" id="date_format_custom_radio" name="date_format" class="settings-field-control" value="\c\u\s\t\o\m">
<label for="date_format_custom_radio">Custom: enter a custom date format in the field below</label> 
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" id="date_format_custom" name="date_format_custom" class="small-text" value="F j, Y" aria-describedby="date_format_custom_radio-custom-description" style="background-repeat: repeat; background-image: none; background-position: 0% 0%; cursor: auto;">
<span class="description" id="date_format_custom_radio-custom-description">Will show as: <span class="example">16/06/2017</span>
</span>
</span>

Which produces:

general_settings_ _wordpress_develop_ _wordpress (I used &nbsp; as a quick hack to align the input field, but you get the idea.)

Visually and using a screenreader this seems to function the same as before. It's not a huge improvement, but it does get rid of some of the double explanation.