Skip to content
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

issue/145 Automated aria levels #146

Merged
merged 4 commits into from
Jul 4, 2022
Merged

issue/145 Automated aria levels #146

merged 4 commits into from
Jul 4, 2022

Conversation

oliverfoster
Copy link
Member

@oliverfoster oliverfoster commented Jun 21, 2022

fixes #145

This is backward compatible, using the current defaults will produce the same outcome. Narrative and accordion will need to be updated to pass an id through for automated calculations.

Current defaults

These are static unless overridden by _ariaLevel on the content.

    "_accessibility": {
        "_ariaLevels": {
            "_menu": 1,
            "_menuGroup": 2,
            "_menuItem": 2,
            "_page": 1,
            "_article": 2,
            "_block": 3,
            "_component": 4,
            "_componentItem": 5,
            "_notify": 1
        }
    }

Possible defaults

These aria levels are calculated dynamically, based upon the existence of a title on the defined parent and the offset through the tree, unless overridden in the tree by _ariaLevel.

    "_accessibility": {
        "_ariaLevels": {
            "_menu": "1",
            "_menuGroup": "@menu+1",
            "_menuItem": "@menu+1",
            "_page": "1",
            "_article": "@page+1",
            "_block": "@article+1",
            "_component": "@block+1",
            "_componentItem": "@component+1",
            "_notify": 1
        }
    }

Examples:
If a component has no article or block title, its aria level will be calculated relative to the page heading level 1, this is as the block and article offsets are not applied.
If a block has an _ariaLevel override, the components will increment from the block override.
_ariaLevel can be specified on any of the content models to override its heading level, this will then be used as the value for the heading level calculations for all descendants.

Changed

  • a11y.ariaLevel from flat arguments to object arguments, with backward compatibility for flat arguments, added id requirement to facilitate aria level calculations in the hierarchy

Added

  • a11y.ariaLevel calculates the aria level if given an id and a relative descriptor @block+1
  • a11y_aria_level handlebars helper

Deprecated

  • a11y_attrs_heading in favour of a11y_aria_level as it's clearer for the handlebars

@oliverfoster oliverfoster requested a review from joe-replin June 21, 2022 14:54
@oliverfoster oliverfoster self-assigned this Jun 21, 2022
@oliverfoster oliverfoster changed the title issue/145 Aautomated aria levels issue/145 Automated aria levels Jun 21, 2022
Co-authored-by: Cahir O'Doherty <41006337+cahirodoherty-learningpool@users.noreply.github.com>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Copy link
Contributor

@joe-replin joe-replin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented into my current build and this is brilliant. Thank you.

js/helpers.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sequential Aria Level Headers
4 participants