@@ -26,6 +26,7 @@ import Fuse from "fuse.js";
2626import { msg , str } from "@lit/localize" ;
2727import { html , nothing , PropertyValues } from "lit" ;
2828import { customElement , property , state } from "lit/decorators.js" ;
29+ import { guard } from "lit/directives/guard.js" ;
2930import { createRef } from "lit/directives/ref.js" ;
3031
3132import PFButton from "@patternfly/patternfly/components/Button/button.css" ;
@@ -324,8 +325,21 @@ export class LibraryPage extends WithSession(AKElement) {
324325 placeholder=${ msg ( "Search for an application by name..." ) }
325326 value=${ ifPresent ( this . query ) }
326327 list=${ ifPresent ( LibraryPage . DataListEnabled , "application-search-options" ) }
328+ aria-describedby="search-action-hint"
327329 />
328330 ${ this . renderDataList ( ) }
331+
332+ < span id ="search-action-hint " class ="sr-only ">
333+ ${ this . selectedApp
334+ ? msg ( str `Press Enter to open ${ this . selectedApp . name } ` , {
335+ id : "user.library.search.enter-to-open-hint" ,
336+ desc : "Screen reader hint to inform the user they can open the selected application by pressing Enter" ,
337+ } )
338+ : msg ( "Type to filter applications" , {
339+ id : "user.library.search.type-to-filter-hint" ,
340+ desc : "Screen reader hint to inform the user they can filter the application list by typing" ,
341+ } ) }
342+ </ span >
329343 </ form >
330344 </ search > ` ;
331345 }
@@ -367,27 +381,56 @@ export class LibraryPage extends WithSession(AKElement) {
367381 return this . renderNoAppsFound ( ) ;
368382 }
369383
370- public override render ( ) {
384+ protected renderApplicationStatusOutput ( ) {
371385 const count = this . visibleApplications . length ;
372386 const { query } = this ;
373387
374- let message : string ;
388+ return guard ( [ count , query ] , ( ) => {
389+ let message : string ;
390+
391+ if ( query ) {
392+ // We must present the count within the label to ensure that the screen reader
393+ // considers the update significant enough to read on each change,
394+ // rather than the on just the first render.
395+ message =
396+ count === 1
397+ ? msg ( str `${ count } application found for "${ query } "` , {
398+ id : "user.library.application-count-singular-with-query" ,
399+ } )
400+ : msg ( str `${ count } applications found for "${ query } "` , {
401+ id : "user.library.application-count-plural-with-query" ,
402+ } ) ;
403+ } else {
404+ message =
405+ count === 1
406+ ? msg ( str `${ count } application available` , {
407+ id : "user.library.application-count-singular" ,
408+ } )
409+ : msg ( str `${ count } applications available` , {
410+ id : "user.library.application-count-plural" ,
411+ } ) ;
412+ }
375413
376- if ( query ) {
377- // We must present the count within the label to ensure that the screen reader
378- // considers the update significant enough to read on each change,
379- // rather than the on just the first render.
380- message =
381- count === 1
382- ? msg ( str `${ count } application found for "${ query } "` )
383- : msg ( str `${ count } applications found for "${ query } "` ) ;
384- } else {
385- message =
386- count === 1
387- ? msg ( str `${ count } application available` )
388- : msg ( str `${ count } applications available` ) ;
389- }
414+ return html `< output
415+ class ="sr-only "
416+ for ="application-search-input "
417+ form ="application-search-form "
418+ aria-live ="polite "
419+ >
420+ < p > ${ message } </ p >
421+ < p >
422+ ${ this . selectedApp
423+ ? msg ( str `Press Enter to open ${ this . selectedApp . name } ` , {
424+ id : "user.library.application-count.enter-to-open-hint" ,
425+ desc : "Screen reader hint to inform the user they can open the selected application by pressing Enter" ,
426+ } )
427+ : nothing }
428+ </ p >
429+ </ output > ` ;
430+ } ) ;
431+ }
390432
433+ protected override render ( ) {
391434 return html `< div class ="pf-c-page__main ">
392435 < div class ="pf-c-page__header pf-c-content ">
393436 < h1 class ="pf-c-page__title "> ${ msg ( "My applications" ) } </ h1 >
@@ -399,15 +442,7 @@ export class LibraryPage extends WithSession(AKElement) {
399442 class ="pf-c-page__main-section "
400443 aria-label =${ msg ( "Application list" ) }
401444 >
402- < output
403- class ="sr-only "
404- for ="application-search-input "
405- form ="application-search-form "
406- aria-live ="polite "
407- >
408- < p > ${ message } </ p >
409- </ output >
410- ${ this . renderState ( ) }
445+ ${ this . renderApplicationStatusOutput } ${ this . renderState ( ) }
411446 </ main >
412447 </ div > ` ;
413448 }
0 commit comments