Skip to content

Commit 2bdce98

Browse files
authored
Merge pull request #13020 from craftcms/feature/dev-445-parent-child-relationship-is-not
Fix parent-child relationship not being conveyed to screen reader users
2 parents fa681e1 + 7c2dee8 commit 2bdce98

File tree

7 files changed

+27
-2
lines changed

7 files changed

+27
-2
lines changed

CHANGELOG-WIP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- 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))
77
- Element index pages now have visually-hidden “Sources” headings for screen readers. ([#12961](https://github.com/craftcms/cms/pull/12961))
88
- Element metadata fields now have visually-hidden “Metadata” headings for screen readers. ([#12961](https://github.com/craftcms/cms/pull/12961))
9+
- Structure elements within element indexes now convey their levels to screen readers. ([#13020](https://github.com/craftcms/cms/pull/13020))
910

1011
### Administration
1112

src/templates/_elements/tableview/elements.twig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@
4444
{%- include '_elements/element' with {
4545
autoReload: false,
4646
} -%}
47+
48+
{%- if structure %}
49+
{% set textAlternative = 'Level {num}'|t('app', {
50+
num: element.level,
51+
}) %}
52+
{{ tag('span', {
53+
class: 'visually-hidden',
54+
data: {
55+
'text-alternative': true,
56+
},
57+
text: textAlternative,
58+
}) }}
59+
{% endif %}
4760
</th>
4861
{% else %}
4962
<td data-title="{{ attribute[1].label }}" data-attr="{{ attribute[0] }}">

src/translations/en/app.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@
830830
'Let each entry choose which sites it should be saved to' => 'Let each entry choose which sites it should be saved to',
831831
'Letterbox' => 'Letterbox',
832832
'Level' => 'Level',
833+
'Level {num}' => 'Level {num}',
833834
'License transferred.' => 'License transferred.',
834835
'License' => 'License',
835836
'Licensed' => 'Licensed',

src/web/assets/cp/CpAsset.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ private function _registerTranslations(View $view): void
213213
'Keep them',
214214
'Label',
215215
'Landscape',
216+
'Level {num}',
216217
'License transferred.',
217218
'Limit',
218219
'Loading',

src/web/assets/cp/dist/cp.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/cp/dist/cp.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/assets/cp/src/js/StructureTableSorter.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,21 @@ Craft.StructureTableSorter = Garnish.DragSort.extend(
241241
oldLevel = $draggee.data('level'),
242242
newLevel = oldLevel + levelDiff,
243243
padding = this._basePadding + this._getLevelIndent(newLevel);
244+
const $structureTextAlternative = $draggee.find(
245+
'[data-text-alternative]'
246+
);
247+
const altText = Craft.t('app', 'Level {num}', {
248+
num: newLevel,
249+
});
244250

245251
$draggee.data('level', newLevel);
246252
$draggee.find('.element').data('level', newLevel);
247253
$draggee
248254
.children('[data-titlecell]:first')
249255
.css('padding-' + Craft.left, padding);
256+
257+
// Update text alternative
258+
$structureTextAlternative.text(altText);
250259
}
251260

252261
this._positionChanged = true;

0 commit comments

Comments
 (0)