Skip to content

Commit

Permalink
refactor: enhance accessibility with ARIA roles and attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyian committed May 23, 2024
1 parent 41dcd94 commit b443d6a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const updateDegreeProgramOverviewDataset = (
};

export default ( data: DegreeProgramApiData[] ) => {
degreeProgramsOverview?.setAttribute( 'aria-busy', 'true' );
degreeProgramsOverview
?.querySelectorAll( SINGLE_PROGRAM_PREVIEW_SELECTOR )
?.forEach( ( element ) => element.remove() );
Expand All @@ -84,9 +85,11 @@ export default ( data: DegreeProgramApiData[] ) => {

if ( ! programs.length ) {
showNoResults();
degreeProgramsOverview?.setAttribute( 'aria-busy', 'false' );
return;
}

hideNoResults();
renderPrograms( programs );
degreeProgramsOverview?.setAttribute( 'aria-busy', 'false' );
};
3 changes: 3 additions & 0 deletions templates/search/collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<ul
class="c-degree-programs-collection <?= esc_attr($viewModeClass) ?>"
data-active-filters="<?= esc_attr(implode(',', $activeFilterNames)) ?>"
role="region"
aria-labelledby="degree-programs-search-title"
aria-live="polite"
>
<?php /** @var DegreeProgramViewTranslated $view */ ?>
<?php // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped ?>
Expand Down
4 changes: 2 additions & 2 deletions templates/search/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@

?>

<section class="c-degree-programs-search" lang="<?= esc_attr(get_bloginfo('language')) ?>">
<section class="c-degree-programs-search" lang="<?= esc_attr(get_bloginfo('language')) ?>" aria-labelledby="degree-programs-search-title">

Check warning on line 40 in templates/search/search.php

View workflow job for this annotation

GitHub Actions / coding-standards-analysis-php / coding-standards-php

Line 40 exceeds 100 characters; contains 139 characters.
<?php if ($hiddenElements->isTitleVisible()) : ?>
<h1 class="c-degree-programs-search__title">
<h1 id="degree-programs-search-title" class="c-degree-programs-search__title">
<?= esc_html_x(
'Degree programs',
'frontoffice: degree programs search form',
Expand Down

0 comments on commit b443d6a

Please sign in to comment.