Administration: Make checkbox column clickable.

Change the `label` for `.check-column` inside list tables to a block filling the entire cell. Improves accessibility by increasing the target area for the control.

Props mitchoyoshitaka, lessbloat, sabernhardt, ogleker, tacoverdo, joostdevalk, karmatosed.

Fixes #21516.
Built from https://develop.svn.wordpress.org/trunk@55954


git-svn-id: http://core.svn.wordpress.org/trunk@55466 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson
2023-06-21 01:54:19 +00:00
parent 17749f1d23
commit 7a4251fae4
18 changed files with 90 additions and 20 deletions

View File

@@ -553,6 +553,28 @@ th.asc a:focus span.sorting-indicator:before {
content: "\f142"; content: "\f142";
} }
.check-column {
position: relative;
}
.check-column .label-covers-full-cell {
width: 100%;
height: 100%;
display: block;
position: absolute;
top: 0;
right: 0;
}
.check-column .label-covers-full-cell input {
position: relative;
z-index: 1;
}
.check-column .label-covers-full-cell:hover + input {
box-shadow: 0 0 0 1px #2271b1;
}
.locked-indicator { .locked-indicator {
display: none; display: none;
margin-right: 6px; margin-right: 6px;

File diff suppressed because one or more lines are too long

View File

@@ -552,6 +552,28 @@ th.asc a:focus span.sorting-indicator:before {
content: "\f142"; content: "\f142";
} }
.check-column {
position: relative;
}
.check-column .label-covers-full-cell {
width: 100%;
height: 100%;
display: block;
position: absolute;
top: 0;
left: 0;
}
.check-column .label-covers-full-cell input {
position: relative;
z-index: 1;
}
.check-column .label-covers-full-cell:hover + input {
box-shadow: 0 0 0 1px #2271b1;
}
.locked-indicator { .locked-indicator {
display: none; display: none;
margin-left: 6px; margin-left: 6px;

File diff suppressed because one or more lines are too long

View File

@@ -884,11 +884,13 @@ class WP_Comments_List_Table extends WP_List_Table {
if ( $this->user_can ) { if ( $this->user_can ) {
?> ?>
<label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>"> <label class="label-covers-full-cell" for="cb-select-<?php echo $comment->comment_ID; ?>">
<span class="screen-reader-text">
<?php <?php
/* translators: Hidden accessibility text. */ /* translators: Hidden accessibility text. */
_e( 'Select comment' ); _e( 'Select comment' );
?> ?>
</span>
</label> </label>
<input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /> <input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" />
<?php <?php

View File

@@ -174,11 +174,13 @@ class WP_Links_List_Table extends WP_List_Table {
$link = $item; $link = $item;
?> ?>
<label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"> <label class="label-covers-full-cell" for="cb-select-<?php echo $link->link_id; ?>">
<span class="screen-reader-text">
<?php <?php
/* translators: Hidden accessibility text. %s: Link name. */ /* translators: Hidden accessibility text. %s: Link name. */
printf( __( 'Select %s' ), $link->link_name ); printf( __( 'Select %s' ), $link->link_name );
?> ?>
</span>
</label> </label>
<input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" /> <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" />
<?php <?php

View File

@@ -1306,9 +1306,11 @@ class WP_List_Table {
if ( ! empty( $columns['cb'] ) ) { if ( ! empty( $columns['cb'] ) ) {
static $cb_counter = 1; static $cb_counter = 1;
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . $columns['cb'] = '<label class="label-covers-full-cell" for="cb-select-all-' . $cb_counter . '">' .
'<span class="screen-reader-text">' .
/* translators: Hidden accessibility text. */ /* translators: Hidden accessibility text. */
__( 'Select All' ) . __( 'Select All' ) .
'</span>' .
'</label>' . '</label>' .
'<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />'; '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
$cb_counter++; $cb_counter++;

View File

@@ -411,11 +411,13 @@ class WP_Media_List_Table extends WP_List_Table {
if ( current_user_can( 'edit_post', $post->ID ) ) { if ( current_user_can( 'edit_post', $post->ID ) ) {
?> ?>
<label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>"> <label class="label-covers-full-cell" for="cb-select-<?php echo $post->ID; ?>">
<span class="screen-reader-text">
<?php <?php
/* translators: Hidden accessibility text. %s: Attachment title. */ /* translators: Hidden accessibility text. %s: Attachment title. */
printf( __( 'Select %s' ), _draft_or_post_title() ); printf( __( 'Select %s' ), _draft_or_post_title() );
?> ?>
</span>
</label> </label>
<input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" /> <input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" />
<?php <?php

View File

@@ -411,11 +411,13 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
if ( ! is_main_site( $blog['blog_id'] ) ) : if ( ! is_main_site( $blog['blog_id'] ) ) :
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] ); $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
?> ?>
<label class="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>"> <label class="label-covers-full-cell" for="blog_<?php echo $blog['blog_id']; ?>">
<span class="screen-reader-text">
<?php <?php
/* translators: %s: Site URL. */ /* translators: %s: Site URL. */
printf( __( 'Select %s' ), $blogname ); printf( __( 'Select %s' ), $blogname );
?> ?>
</span>
</label> </label>
<input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]" <input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]"
value="<?php echo esc_attr( $blog['blog_id'] ); ?>" /> value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />

View File

@@ -512,8 +512,8 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$theme = $item; $theme = $item;
$checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) ); $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
?> ?>
<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" /> <label class="label-covers-full-cell" for="<?php echo $checkbox_id; ?>" >
<label class="screen-reader-text" for="<?php echo $checkbox_id; ?>" > <span class="screen-reader-text">
<?php <?php
printf( printf(
/* translators: Hidden accessibility text. %s: Theme name */ /* translators: Hidden accessibility text. %s: Theme name */
@@ -521,7 +521,9 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
$theme->display( 'Name' ) $theme->display( 'Name' )
); );
?> ?>
</span>
</label> </label>
<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" />
<?php <?php
} }

View File

@@ -235,11 +235,13 @@ class WP_MS_Users_List_Table extends WP_List_Table {
return; return;
} }
?> ?>
<label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"> <label class="label-covers-full-cell" for="blog_<?php echo $user->ID; ?>">
<span class="screen-reader-text">
<?php <?php
/* translators: Hidden accessibility text. %s: User login. */ /* translators: Hidden accessibility text. %s: User login. */
printf( __( 'Select %s' ), $user->user_login ); printf( __( 'Select %s' ), $user->user_login );
?> ?>
</span>
</label> </label>
<input type="checkbox" id="blog_<?php echo $user->ID; ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ); ?>" /> <input type="checkbox" id="blog_<?php echo $user->ID; ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ); ?>" />
<?php <?php

View File

@@ -982,7 +982,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
$checkbox = ''; $checkbox = '';
} else { } else {
$checkbox = sprintf( $checkbox = sprintf(
'<label class="screen-reader-text" for="%1$s">%2$s</label>' . '<label class="label-covers-full-cell" for="%1$s"><span class="screen-reader-text">%2$s</span></label>' .
'<input type="checkbox" name="checked[]" value="%3$s" id="%1$s" />', '<input type="checkbox" name="checked[]" value="%3$s" id="%1$s" />',
$checkbox_id, $checkbox_id,
/* translators: Hidden accessibility text. %s: Plugin name. */ /* translators: Hidden accessibility text. %s: Plugin name. */

View File

@@ -1012,11 +1012,13 @@ class WP_Posts_List_Table extends WP_List_Table {
*/ */
if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) : if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) :
?> ?>
<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"> <label class="label-covers-full-cell" for="cb-select-<?php the_ID(); ?>">
<span class="screen-reader-text">
<?php <?php
/* translators: %s: Post title. */ /* translators: %s: Post title. */
printf( __( 'Select %s' ), _draft_or_post_title() ); printf( __( 'Select %s' ), _draft_or_post_title() );
?> ?>
</span>
</label> </label>
<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" /> <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
<div class="locked-indicator"> <div class="locked-indicator">

View File

@@ -415,7 +415,13 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
* @return string Checkbox column markup. * @return string Checkbox column markup.
*/ */
public function column_cb( $item ) { public function column_cb( $item ) {
return sprintf( '<input type="checkbox" name="request_id[]" value="%1$s" /><span class="spinner"></span>', esc_attr( $item->ID ) ); return sprintf(
'<label class="label-covers-full-cell" for="requester_%1$s"><span class="screen-reader-text">%2$s</span></label>' .
'<input type="checkbox" name="request_id[]" id="requester_%1$s" value="%1$s" /><span class="spinner"></span>',
esc_attr( $item->ID ),
/* translators: Hidden accessibility text. %s: Email address. */
sprintf( __( 'Select %s' ), $item->email )
);
} }
/** /**

View File

@@ -357,7 +357,7 @@ class WP_Terms_List_Table extends WP_List_Table {
if ( current_user_can( 'delete_term', $tag->term_id ) ) { if ( current_user_can( 'delete_term', $tag->term_id ) ) {
return sprintf( return sprintf(
'<label class="screen-reader-text" for="cb-select-%1$s">%2$s</label>' . '<label class="label-covers-full-cell" for="cb-select-%1$s"><span class="screen-reader-text">%2$s</span></label>' .
'<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />', '<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />',
$tag->term_id, $tag->term_id,
/* translators: Hidden accessibility text. %s: Taxonomy term name. */ /* translators: Hidden accessibility text. %s: Taxonomy term name. */

View File

@@ -523,7 +523,7 @@ class WP_Users_List_Table extends WP_List_Table {
// Set up the checkbox (because the user is editable, otherwise it's empty). // Set up the checkbox (because the user is editable, otherwise it's empty).
$checkbox = sprintf( $checkbox = sprintf(
'<label class="screen-reader-text" for="user_%1$s">%2$s</label>' . '<label class="label-covers-full-cell" for="user_%1$s"><span class="screen-reader-text">%2$s</span></label>' .
'<input type="checkbox" name="users[]" id="user_%1$s" class="%3$s" value="%1$s" />', '<input type="checkbox" name="users[]" id="user_%1$s" class="%3$s" value="%1$s" />',
$user_object->ID, $user_object->ID,
/* translators: Hidden accessibility text. %s: User login. */ /* translators: Hidden accessibility text. %s: User login. */

View File

@@ -571,13 +571,15 @@ function list_plugin_updates() {
<tr> <tr>
<td class="check-column"> <td class="check-column">
<?php if ( $compatible_php ) : ?> <?php if ( $compatible_php ) : ?>
<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" /> <label for="<?php echo $checkbox_id; ?>" class="label-covers-full-cell">
<label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"> <span class="screen-reader-text">
<?php <?php
/* translators: Hidden accessibility text. %s: Plugin name. */ /* translators: Hidden accessibility text. %s: Plugin name. */
printf( __( 'Select %s' ), $plugin_data->Name ); printf( __( 'Select %s' ), $plugin_data->Name );
?> ?>
</span>
</label> </label>
<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" />
<?php endif; ?> <?php endif; ?>
</td> </td>
<td class="plugin-title"><p> <td class="plugin-title"><p>
@@ -745,13 +747,15 @@ function list_theme_updates() {
<tr> <tr>
<td class="check-column"> <td class="check-column">
<?php if ( $compatible_wp && $compatible_php ) : ?> <?php if ( $compatible_wp && $compatible_php ) : ?>
<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" /> <label for="<?php echo $checkbox_id; ?>" class="label-covers-full-cell">
<label for="<?php echo $checkbox_id; ?>" class="screen-reader-text"> <span class="screen-reader-text">
<?php <?php
/* translators: Hidden accessibility text. %s: Theme name. */ /* translators: Hidden accessibility text. %s: Theme name. */
printf( __( 'Select %s' ), $theme->display( 'Name' ) ); printf( __( 'Select %s' ), $theme->display( 'Name' ) );
?> ?>
</span>
</label> </label>
<input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
<?php endif; ?> <?php endif; ?>
</td> </td>
<td class="plugin-title"><p> <td class="plugin-title"><p>

View File

@@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.3-alpha-55953'; $wp_version = '6.3-alpha-55954';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.