WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#39952 new defect (bug)

Category Dropdown Widget: required spacing issue on attachments template

Reported by: tribalNerd Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7.2
Component: General Keywords: reporter-feedback
Focuses: Cc:

Description

This issue only happens on the attachments.php template, all other primary templates don't appear to have the issue.

When using the category widget as a dropdown, the select statement looks like: <selectname='cat' rather than <select name='cat'

The file, category-template.php output statement is:

<?php
$output = "<select $required name='$name' id='$id' class='$class' $tab_index_attribute>\n";

Removing $required corrects the issue.

Setting required to true also corrects the issue.

<?php
function categories_dropdown($args) {
    $args['required'] = true;
    return $args;
}
add_filter( 'widget_categories_dropdown_args', 'categories_dropdown' );

Which returns:

<select required="" name="cat" id="cat" class="postform">

While this does correct the issue, the required="" isn't correct either, it should be: required without the =""

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select

It should also have aria-required="true" for Safari.

Change History (1)

#1 in reply to: ↑ description @subrataemfluence
2 years ago

  • Keywords reporter-feedback added

Would you mind telling how to reproduce the issue? An example code would be handy.

Replying to tribalNerd:

This issue only happens on the attachments.php template, all other primary templates don't appear to have the issue.

When using the category widget as a dropdown, the select statement looks like: <selectname='cat' rather than <select name='cat'

The file, category-template.php output statement is:

<?php
$output = "<select $required name='$name' id='$id' class='$class' $tab_index_attribute>\n";

Removing $required corrects the issue.

Setting required to true also corrects the issue.

<?php
function categories_dropdown($args) {
    $args['required'] = true;
    return $args;
}
add_filter( 'widget_categories_dropdown_args', 'categories_dropdown' );

Which returns:

<select required="" name="cat" id="cat" class="postform">

While this does correct the issue, the required="" isn't correct either, it should be: required without the =""

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select

It should also have aria-required="true" for Safari.

Note: See TracTickets for help on using tickets.