Commit 23f28fa
authored
chore(components, accessibility): improve
## 📋 Summary
This PR improves the semantic structure and accessibility of the
`post-header` and `post-mainnavigation` components.
---
## Key Question
**Original Question from
[[#6687](https://github.com/swisspost/design-system/issues/6687)]**
> "Is it correct for the `<nav>` element from the `post-mainnavigation`
to be placed inside a `<header>` element?"
### Decision:
**Yes**, placing `<nav>` inside `<header>` is correct and follows W3C
best practices.
### Why this is valid:
Both W3C and MDN provide examples showing navigation elements nested
within the header. According to **MDN**:
> "Even if it's not mandatory, it's common practice to put the main
navigation menu within the main header."
**Source:** [[MDN - WAI-ARIA
Basics](https://developer.mozilla.org/de/docs/Learn_web_development/Core/Accessibility/WAI-ARIA_basics?utm_source=chatgpt.com#wegweiserlandmarken)](https://developer.mozilla.org/de/docs/Learn_web_development/Core/Accessibility/WAI-ARIA_basics?utm_source=chatgpt.com#wegweiserlandmarken)
### Trusted Source Examples:
1. [[MDN - WAI-ARIA Basics: Landmark
Navigation](https://developer.mozilla.org/de/docs/Learn_web_development/Core/Accessibility/WAI-ARIA_basics?utm_source=chatgpt.com#wegweiserlandmarken)](https://developer.mozilla.org/de/docs/Learn_web_development/Core/Accessibility/WAI-ARIA_basics?utm_source=chatgpt.com#wegweiserlandmarken)
2. [[W3C Design System - Header with
Navigation](https://design-system.w3.org/code/header-nav.html)](https://design-system.w3.org/code/header-nav.html)
---
## Changes Made
### 1. Added Semantic `<header>` Element with `role="banner"`
#### Accessibility Tree Comparison:
**BEFORE:**
<img width="452" alt="Accessibility tree before changes"
src="https://github.com/user-attachments/assets/6e7e236e-1d61-45a4-b9d9-3e8a3b044fc2"
/>
**AFTER:**
<img width="571" alt="Accessibility tree after changes"
src="https://github.com/user-attachments/assets/265d5a70-c3b0-477a-be6b-0dacc5d52fc5"
/>
#### Why `role="banner"` is needed:
<img width="1029" alt="W3C guidance on role banner"
src="https://github.com/user-attachments/assets/d2bb7621-23bf-4b46-b07a-38fbe5e7cb76"
/>
---
### 2. Added Required `caption` Prop to `post-mainnavigation`
---
### 3. Moved Event Listener to Shadow Root
**Problem with host listener:**
When the event listener is attached to the host element, screen readers
detect the entire component as interactive and announce it as
**"clickable banner landmark"**, which is incorrect and confusing for
users with assistive technology.
**Solution:**
Changed from `this.host.addEventListener()` to
`this.host.shadowRoot.addEventListener()`.post-header semantics (#6841)1 parent 2c5da86 commit 23f28fa
File tree
16 files changed
+97
-56
lines changed- .changeset
- packages
- components-angular/projects/consumer-app/src/app
- components
- cypress/fixtures
- src
- components
- post-header
- documentation/src/stories
- components
- back-to-top
- header
- renderers
- guidelines/header with custom logo link
- raw-components/megadropdown
- nextjs-integration/src/app/ssr
16 files changed
+97
-56
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
311 | 315 | | |
312 | 316 | | |
313 | 317 | | |
| |||
1326 | 1330 | | |
1327 | 1331 | | |
1328 | 1332 | | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
1329 | 1337 | | |
1330 | 1338 | | |
1331 | 1339 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
Lines changed: 46 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | 124 | | |
126 | 125 | | |
127 | 126 | | |
| |||
141 | 140 | | |
142 | 141 | | |
143 | 142 | | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
| |||
417 | 419 | | |
418 | 420 | | |
419 | 421 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
428 | 450 | | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
446 | 463 | | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
| 464 | + | |
| 465 | + | |
462 | 466 | | |
463 | 467 | | |
464 | 468 | | |
| |||
Lines changed: 16 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
26 | 37 | | |
27 | 38 | | |
28 | 39 | | |
| |||
34 | 45 | | |
35 | 46 | | |
36 | 47 | | |
| 48 | + | |
| 49 | + | |
37 | 50 | | |
38 | 51 | | |
39 | 52 | | |
| |||
200 | 213 | | |
201 | 214 | | |
202 | 215 | | |
203 | | - | |
| 216 | + | |
204 | 217 | | |
205 | 218 | | |
206 | 219 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
0 commit comments