Skip to content

Commit 864ceb4

Browse files
authored
fix remaining a11y issues (#55930)
1 parent ad636dc commit 864ceb4

File tree

2 files changed

+47
-45
lines changed

2 files changed

+47
-45
lines changed

src/search/components/input/AskAIResults.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export function AskAIResults({
373373
}, [query])
374374

375375
return (
376-
<div className={styles.container}>
376+
<div id="ask-ai-result-container" role="region" className={styles.container}>
377377
{!aiCouldNotAnswer && references && references.length > 0 ? (
378378
<>
379379
<ActionList className={styles.referencesList} showDividers>
@@ -398,7 +398,6 @@ export function AskAIResults({
398398
}}
399399
key={`reference-${index}`}
400400
id={`search-option-reference-${index + referencesIndexOffset}`}
401-
role="option"
402401
tabIndex={-1}
403402
onSelect={() => {
404403
referenceOnSelect(source.url)

src/search/components/input/SearchOverlay.tsx

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -601,29 +601,33 @@ export function SearchOverlay({
601601
{aiSearchError && (
602602
<>
603603
<ActionList.Divider key="error-top-divider" />
604-
<ActionList.GroupHeading
605-
as="h3"
606-
tabIndex={-1}
607-
aria-label={t('search.overlay.ai_suggestions_list_aria_label')}
608-
>
609-
<CopilotIcon className="mr-1" />
610-
{t('search.overlay.ai_autocomplete_list_heading')}
611-
</ActionList.GroupHeading>
612-
<Box
613-
sx={{
614-
padding: '0 16px 0 16px',
615-
}}
616-
>
617-
<Banner
618-
tabIndex={0}
619-
className={styles.errorBanner}
620-
title={t('search.failure.ai_title')}
621-
description={t('search.failure.description')}
622-
variant="info"
623-
aria-live="assertive"
624-
role="alert"
625-
/>
626-
</Box>
604+
<li tabIndex={-1}>
605+
<ActionList.GroupHeading
606+
as="h3"
607+
tabIndex={-1}
608+
aria-label={t('search.overlay.ai_suggestions_list_aria_label')}
609+
>
610+
<CopilotIcon className="mr-1" />
611+
{t('search.overlay.ai_autocomplete_list_heading')}
612+
</ActionList.GroupHeading>
613+
</li>
614+
<li>
615+
<Box
616+
sx={{
617+
padding: '0 16px 0 16px',
618+
}}
619+
>
620+
<Banner
621+
tabIndex={0}
622+
className={styles.errorBanner}
623+
title={t('search.failure.ai_title')}
624+
description={t('search.failure.description')}
625+
variant="info"
626+
aria-live="assertive"
627+
role="alert"
628+
/>
629+
</Box>
630+
</li>
627631
<ActionList.Divider key="error-bottom-divider" />
628632
</>
629633
)}
@@ -721,7 +725,8 @@ export function SearchOverlay({
721725
leadingVisual={<SearchIcon />}
722726
aria-labelledby={overlayHeadingId}
723727
role="combobox"
724-
aria-controls="search-suggestions-list"
728+
// In AskAI the search input not longer "controls" the suggestions list, because there is no list, so we remove the aria-controls attribute
729+
aria-controls={isAskAIState ? 'ask-ai-result-container' : 'search-suggestions-list'}
725730
aria-expanded={combinedOptions.length > 0}
726731
aria-activedescendant={
727732
selectedIndex >= 0
@@ -883,21 +888,23 @@ function renderSearchGroups(
883888
if (isInAskAIState) {
884889
groups.push(
885890
<ActionList.Group key="ai" data-testid="ask-ai">
886-
<AskAIResults
887-
query={askAIState.aiQuery}
888-
debug={askAIState.debug}
889-
version={askAIState.currentVersion}
890-
setAISearchError={askAIState.setAISearchError}
891-
references={askAIState.references}
892-
setReferences={askAIState.setReferences}
893-
referencesIndexOffset={askAIState.referencesIndexOffset}
894-
referenceOnSelect={askAIState.referenceOnSelect}
895-
selectedIndex={selectedIndex}
896-
askAIEventGroupId={askAIState.askAIEventGroupId}
897-
aiCouldNotAnswer={askAIState.aiCouldNotAnswer}
898-
setAICouldNotAnswer={askAIState.setAICouldNotAnswer}
899-
listElementsRef={listElementsRef}
900-
/>
891+
<li tabIndex={-1}>
892+
<AskAIResults
893+
query={askAIState.aiQuery}
894+
debug={askAIState.debug}
895+
version={askAIState.currentVersion}
896+
setAISearchError={askAIState.setAISearchError}
897+
references={askAIState.references}
898+
setReferences={askAIState.setReferences}
899+
referencesIndexOffset={askAIState.referencesIndexOffset}
900+
referenceOnSelect={askAIState.referenceOnSelect}
901+
selectedIndex={selectedIndex}
902+
askAIEventGroupId={askAIState.askAIEventGroupId}
903+
aiCouldNotAnswer={askAIState.aiCouldNotAnswer}
904+
setAICouldNotAnswer={askAIState.setAICouldNotAnswer}
905+
listElementsRef={listElementsRef}
906+
/>
907+
</li>
901908
</ActionList.Group>,
902909
)
903910
}
@@ -935,7 +942,6 @@ function renderSearchGroups(
935942
<ActionList.Item
936943
key={`general-${index}`}
937944
id={`search-option-general-${index}`}
938-
role="option"
939945
className={styles.noResultsFound}
940946
tabIndex={-1}
941947
aria-label={t('search.overlay.no_results_found')}
@@ -953,7 +959,6 @@ function renderSearchGroups(
953959
<ActionList.Item
954960
key={`general-${index}`}
955961
id={`search-option-general-${index}`}
956-
role="option"
957962
tabIndex={-1}
958963
active={isActive}
959964
onSelect={() => performGeneralSearch()}
@@ -986,7 +991,6 @@ function renderSearchGroups(
986991
<ActionList.Item
987992
key={`general-${index}`}
988993
id={`search-option-general-${index}`}
989-
role="option"
990994
aria-describedby="search-suggestions-list"
991995
onSelect={() =>
992996
option.isViewAllResults ? performGeneralSearch() : generalSearchResultOnSelect(option)
@@ -1062,7 +1066,6 @@ function renderSearchGroups(
10621066
<ActionList.Item
10631067
key={`ai-${indexWithOffset}`}
10641068
id={`search-option-ai-${indexWithOffset}`}
1065-
role="option"
10661069
aria-describedby="copilot-suggestions"
10671070
onSelect={() => aiAutocompleteOnSelect(option)}
10681071
active={isActive}

0 commit comments

Comments
 (0)