Skip to content

Update: provide alternative title text override for menu button ARIA label (fixes #214) #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ The following attributes, set within *contentObjects.json*, configure the defaul

**displayTitle** (string): This text is displayed on the menu item.

>**titleAriaLabel** (string): This will be read out by screen readers instead of **title** for the menu button text. Use if **title** contains punctuation or html syntax that shouldn't be read.

**body** (string): Optional text that appears on the menu item. Often used to inform the learner about the menu choice. If no **pageBody** is supplied, this text will also appear as the body text of the page header.

**pageBody** (string): Optional text that appears as the body text of the page header. If this text is not provided, the **body** text will be used (if it is supplied). Reference [*adapt-contrib-vanilla/templates/page.hbs*](https://github.com/adaptlearning/adapt-contrib-vanilla/blob/master/templates/page.hbs).
Expand Down
1 change: 1 addition & 0 deletions example.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"_isHidden": false,
"title": "Welcome to Adapt Learning",
"displayTitle": "Welcome to Adapt Learning",
"titleAriaLabel": "",
"body": "This page contains a working Adapt page with all core bundled components and plugins working.",
"_graphic": {
"alt": "",
Expand Down
9 changes: 9 additions & 0 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,15 @@
"type": "object",
"required": false,
"properties": {
"titleAriaLabel": {
"type": "string",
"inputType": "Text",
"validators": [],
"title": "Title ARIA label",
"help": "Alternative title text read out by screen readers for the menu button text"
"required": false,
"translatable": true
},
"_renderAsGroup": {
"type": "boolean",
"required": false,
Expand Down
9 changes: 9 additions & 0 deletions schema/contentobject.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
"title": "Box Menu",
"default": {},
"properties": {
"titleAriaLabel": {
"type": "string",
"title": "Title ARIA label",
"description": "Alternative title text read out by screen readers for the menu button text",
"default": "",
"_adapt": {
"translatable": true
}
},
"_renderAsGroup": {
"type": "boolean",
"title": "Make this a parent group of menu items",
Expand Down
4 changes: 3 additions & 1 deletion templates/boxMenuItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function BoxMenuItem (props) {
_isLocked,
_isComplete,
title,
titleAriaLabel,
_isOptional,
_nthChild,
_totalChild
Expand All @@ -31,8 +32,9 @@ export default function BoxMenuItem (props) {
const locked = _isLocked ? _globals?._accessibility?._ariaLabels?.locked : linkText;
const optional = _isOptional ? _globals?._accessibility?._ariaLabels?.optional : '';
const itemCount = compile(_globals?._menu?._boxMenu?.itemCount || '', { _nthChild, _totalChild });
const itemTitle = titleAriaLabel || title;
const ariaLabel = [
completion, locked, `${title}.`, `${itemCount}.`, `${optional}`
completion, locked, `${itemTitle}.`, `${itemCount}.`, `${optional}`
].filter(Boolean).join(' ');

return (
Expand Down
Loading