Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/js/_enqueues/admin/site-health.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ jQuery( function( $ ) {
$( '.health-check-accordion' ).on( 'click', '.health-check-accordion-trigger', function() {
var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) );

if ( $( this ).prop( 'id' ) ) {
window.location.hash = $( this ).prop( 'id' );
}

if ( isExpanded ) {
$( this ).attr( 'aria-expanded', 'false' );
$( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', true );
Expand All @@ -53,6 +57,20 @@ jQuery( function( $ ) {
}
} );

/* global setTimeout */
wp.domReady( function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be sufficient for async tests which run after the page has loaded?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@westonruter No, wp.domReady() only waits for the DOM to be ready (like DOMContentLoaded), not for async content or tests that run after the page has loaded.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So then isn't this running too early? It should run after all of the async tests have completed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Site Tools > Info tab data is loaded statically, so there aren't any async tests involved. In this case, wp.domReady() is fine to use. Existing test reports also show no issues, so it seems to be working as expected.

Are you seeing any problem with it?

// Get hash from query string and open the related accordion.
var hash = window.location.hash;

if ( hash ) {
var requestedPanel = $( hash );

if ( requestedPanel.is( '.health-check-accordion-trigger' ) ) {
requestedPanel.trigger( 'click' );
}
}
} );

// Site Health test handling.

$( '.site-health-view-passed' ).on( 'click', function() {
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/site-health-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

?>
<h3 class="health-check-accordion-heading">
<button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" type="button">
<button id="health-check-section-<?php echo esc_attr( $section ); ?>" aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" type="button">
<span class="title">
<?php echo esc_html( $details['label'] ); ?>
<?php
Expand Down
Loading