Skip to content

Commit f87d4e6

Browse files
committed
accessibility fixes
1 parent 17b596b commit f87d4e6

File tree

6 files changed

+19
-10
lines changed

6 files changed

+19
-10
lines changed

plugins/wpgraphql-logging/assets/css/view/wp-graphql-logging-view.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
.wpgraphql-logging-details pre.wpgraphql-logging-context,
1010
.wpgraphql-logging-details pre.wpgraphql-logging-extra {
1111
white-space: pre-wrap;
12+
word-wrap: break-word;
13+
word-break: break-word;
14+
overflow-wrap: break-word;
1215
max-height: 540px;
13-
overflow-y: scroll;
16+
overflow-y: auto;
17+
overflow-x: auto;
1418
padding: 15px;
1519
border: 1px solid #ddd;
1620
border-radius: 4px;

plugins/wpgraphql-logging/assets/js/settings/wp-graphql-logging-settings.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ document.addEventListener("DOMContentLoaded", function () {
6363
);
6464

6565
function checkLogPointsSelection() {
66+
const descriptionId = "log-points-description";
6667
const anyLogPointsSelected = logPointsInput.selectedOptions.length > 0;
6768

6869
const existingDescription =
69-
logPointsInput.parentElement.querySelector(".description");
70+
logPointsInput.parentElement.querySelector(`#${descriptionId}`);
7071
if (existingDescription) {
7172
existingDescription.remove();
7273
}
@@ -75,8 +76,9 @@ document.addEventListener("DOMContentLoaded", function () {
7576
if (enableCheckbox?.checked && !anyLogPointsSelected) {
7677
const description = document.createElement("p");
7778

78-
if (!logPointsInput.parentElement.querySelector(".description")) {
79+
if (!logPointsInput.parentElement.querySelector(`#${descriptionId}`)) {
7980
description.className = "description";
81+
description.id = descriptionId;
8082
description.textContent =
8183
"If you don't select any log points, no data will be logged.";
8284
description.style.marginLeft = "25px";

plugins/wpgraphql-logging/src/Admin/Settings/Fields/Field/SelectField.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function render_field( array $option_value, string $setting_key, string $
6161
$html .= 'name="' . esc_attr( $field_name ) . ( $this->multiple ? '[]' : '' ) . '" ';
6262
$html .= 'id="' . esc_attr( $this->get_id() ) . '" ';
6363
$html .= 'class="' . esc_attr( $this->css_class ) . '" ';
64+
$html .= 'aria-labelledby="' . esc_attr( $field_name ) . '-tooltip" ';
6465

6566
if ( $this->multiple ) {
6667
$html .= 'multiple="multiple" ';

plugins/wpgraphql-logging/src/Admin/View/List/ListTable.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,11 @@ public function column_cb( $item ): string {
280280
if ( ! $item instanceof WordPressDatabaseEntity ) {
281281
return '';
282282
}
283+
$log_id = $item->get_id();
283284
return sprintf(
284-
'<input type="checkbox" name="log[]" value="%d" />',
285-
$item->get_id()
285+
'<label class="screen-reader-text" for="cb-select-%1$d">%2$s</label><input id="cb-select-%1$d" type="checkbox" name="log[]" value="%1$d" />',
286+
$item->get_id(),
287+
sprintf( __( 'Select log entry %d', 'wpgraphql-logging' ), $log_id )
286288
);
287289
}
288290

@@ -413,7 +415,7 @@ protected function format_code(string $code): string {
413415
if ( empty( $code ) ) {
414416
return '';
415417
}
416-
return '<pre class="wpgraphql-logging-list-table-query">' . esc_html( $code ) . '</pre>';
418+
return '<pre class="wpgraphql-logging-list-table-query" tabindex="0">' . esc_html( $code ) . '</pre>';
417419
}
418420

419421
/**

plugins/wpgraphql-logging/src/Admin/View/Templates/WPGraphQLLoggerFilters.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class="wpgraphql-logging-datepicker"
3737
value="<?php echo esc_attr( $wpgraphql_logging_current_end_date ); ?>"
3838
autocomplete="off" />
3939

40-
<select name="level_filter">
40+
<select name="level_filter" aria-label="<?php esc_attr_e( 'Filter by level', 'wpgraphql-logging' ); ?>">
4141
<option value="">All Levels</option>
4242
<?php foreach ( $wpgraphql_logging_log_levels as $wpgraphql_logging_level ) : ?>
4343
<option value="<?php echo esc_attr( $wpgraphql_logging_level ); ?>" <?php selected( $wpgraphql_logging_current_level, $wpgraphql_logging_level ); ?>>

plugins/wpgraphql-logging/src/Admin/View/Templates/WPGraphQLLoggerView.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@
6565
</tr>
6666
<tr>
6767
<th><?php esc_html_e( 'Query', 'wpgraphql-logging' ); ?></th>
68-
<td><pre class="wpgraphql-logging-query"><?php echo esc_html( (string) $log->get_query() ); ?></pre></td>
68+
<td><pre class="wpgraphql-logging-query" tabindex="0"><?php echo esc_html( (string) $log->get_query() ); ?></pre></td>
6969
</tr>
7070
<tr>
7171
<th><?php esc_html_e( 'Context', 'wpgraphql-logging' ); ?></th>
72-
<td><pre class="wpgraphql-logging-context"><?php echo esc_html( (string) wp_json_encode( $log->get_context(), JSON_PRETTY_PRINT ) ); ?></pre></td>
72+
<td><pre class="wpgraphql-logging-context" tabindex="0"><?php echo esc_html( (string) wp_json_encode( $log->get_context(), JSON_PRETTY_PRINT ) ); ?></pre></td>
7373
</tr>
7474
<tr>
7575
<th><?php esc_html_e( 'Extra', 'wpgraphql-logging' ); ?></th>
76-
<td><pre class="wpgraphql-logging-extra"><?php echo esc_html( (string) wp_json_encode( $log->get_extra(), JSON_PRETTY_PRINT ) ); ?></pre></td>
76+
<td><pre class="wpgraphql-logging-extra" tabindex="0"><?php echo esc_html( (string) wp_json_encode( $log->get_extra(), JSON_PRETTY_PRINT ) ); ?></pre></td>
7777
</tr>
7878
</tbody>
7979
</table>

0 commit comments

Comments
 (0)