From 5806cfcb10bb162f0deefcae8e8e78a2e5a86d43 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Tue, 25 May 2021 10:55:10 +0100 Subject: [PATCH] Merge pull request #4082 from overleaf/ae-aria-symbol-palette Improve ARIA validation of symbol palette GitOrigin-RevId: 7624262b454d03d1a56d4a75b951fca3261b6e13 --- .../components/symbol-palette-body.js | 57 +++++++++++-------- .../components/symbol-palette-item.js | 9 ++- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/services/web/frontend/js/features/symbol-palette/components/symbol-palette-body.js b/services/web/frontend/js/features/symbol-palette/components/symbol-palette-body.js index d6a8908354..b7b90d6312 100644 --- a/services/web/frontend/js/features/symbol-palette/components/symbol-palette-body.js +++ b/services/web/frontend/js/features/symbol-palette/components/symbol-palette-body.js @@ -13,35 +13,44 @@ export default function SymbolPaletteBody({ }) { const { t } = useTranslation() - // not searching: show the symbols grouped by category - if (!filteredSymbols) { + // searching with matches: show the matched symbols + // searching with no matches: show a message + // note: include empty tab panels so that aria-controls on tabs can still reference the panel ids + if (filteredSymbols) { return ( - - {categories.map(category => ( - - - - ))} - + <> + {filteredSymbols.length ? ( + + ) : ( +
{t('no_symbols_found')}
+ )} + + + {categories.map(category => ( + + ))} + + ) } - // searching with no matches: show a message - if (!filteredSymbols.length) { - return
{t('no_symbols_found')}
- } - - // searching with matches: show the matched symbols + // not searching: show the symbols grouped by category return ( - + + {categories.map(category => ( + + + + ))} + ) } SymbolPaletteBody.propTypes = { diff --git a/services/web/frontend/js/features/symbol-palette/components/symbol-palette-item.js b/services/web/frontend/js/features/symbol-palette/components/symbol-palette-item.js index 9ffaf1db63..c17852451e 100644 --- a/services/web/frontend/js/features/symbol-palette/components/symbol-palette-item.js +++ b/services/web/frontend/js/features/symbol-palette/components/symbol-palette-item.js @@ -30,9 +30,7 @@ export default function SymbolPaletteItem({
{symbol.description}
- +
{symbol.command}
{symbol.notes && (
{symbol.notes}
)} @@ -47,9 +45,10 @@ export default function SymbolPaletteItem({ tabIndex={focused ? 0 : -1} ref={buttonRef} role="option" - aria-selected={focused} + aria-label={symbol.description} + aria-selected={focused ? 'true' : 'false'} > - + {symbol.character} )