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

Fix parent-child relationship not being conveyed to screen reader users #13020

Merged
merged 14 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Image assets’ thumbnails and `<img>` tags generated via `craft\element\Asset::getImg()` no longer use the assets’ titles as `alt` fallback values. ([#12854](https://github.com/craftcms/cms/pull/12854))
- Element index pages now have visually-hidden “Sources” headings for screen readers. ([#12961](https://github.com/craftcms/cms/pull/12961))
- Element metadata fields now have visually-hidden “Metadata” headings for screen readers. ([#12961](https://github.com/craftcms/cms/pull/12961))
- Structure elements within element indexes now convey their levels to screen readers. ([#13020](https://github.com/craftcms/cms/pull/13020))

### Administration

Expand Down
13 changes: 13 additions & 0 deletions src/templates/_elements/tableview/elements.twig
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@
{%- include '_elements/element' with {
autoReload: false,
} -%}

{%- if structure %}
{% set textAlternative = 'Level {num}'|t('app', {
num: element.level,
}) %}
{{ tag('span', {
class: 'visually-hidden',
data: {
'text-alternative': true,
},
text: textAlternative,
}) }}
{% endif %}
</th>
{% else %}
<td data-title="{{ attribute[1].label }}" data-attr="{{ attribute[0] }}">
Expand Down
1 change: 1 addition & 0 deletions src/translations/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,7 @@
'Let each entry choose which sites it should be saved to' => 'Let each entry choose which sites it should be saved to',
'Letterbox' => 'Letterbox',
'Level' => 'Level',
'Level {num}' => 'Level {num}',
'License transferred.' => 'License transferred.',
'License' => 'License',
'Licensed' => 'Licensed',
Expand Down
1 change: 1 addition & 0 deletions src/web/assets/cp/CpAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ private function _registerTranslations(View $view): void
'Keep them',
'Label',
'Landscape',
'Level {num}',
'License transferred.',
'Limit',
'Loading',
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js.map

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions src/web/assets/cp/src/js/StructureTableSorter.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,21 @@ Craft.StructureTableSorter = Garnish.DragSort.extend(
oldLevel = $draggee.data('level'),
newLevel = oldLevel + levelDiff,
padding = this._basePadding + this._getLevelIndent(newLevel);
const $structureTextAlternative = $draggee.find(
'[data-text-alternative]'
);
const altText = Craft.t('app', 'Level {num}', {
num: newLevel,
});

$draggee.data('level', newLevel);
$draggee.find('.element').data('level', newLevel);
$draggee
.children('[data-titlecell]:first')
.css('padding-' + Craft.left, padding);

// Update text alternative
$structureTextAlternative.text(altText);
}

this._positionChanged = true;
Expand Down