@@ -551,6 +551,7 @@ export default {
551
551
-->
552
552
<Teleport v-if="ncContentSelector && !open && !noToggle" :to="ncContentSelector">
553
553
<NcButton :aria-label="t('Open sidebar')"
554
+ ref="toggle"
554
555
class="app-sidebar__toggle"
555
556
:class="toggleClasses"
556
557
variant="tertiary"
@@ -565,6 +566,15 @@ export default {
565
566
</NcButton>
566
567
</Teleport>
567
568
569
+ <!-- Fallback for screen reader navigation in case header was not rendered -->
570
+ <h2 v-if="hasHeaderAriaFallback"
571
+ :id="`app-sidebar-vue-${uid}__header`"
572
+ ref="headerAriaFallback"
573
+ :tabindex="0"
574
+ class="hidden-visually">
575
+ {{ name }}
576
+ </h2>
577
+
568
578
<header :class="{
569
579
'app-sidebar-header--with-figure': isSlotPopulated($slots.header?.()) || background,
570
580
'app-sidebar-header--compact': compact,
@@ -957,6 +967,9 @@ export default {
957
967
hasFigureClickListener() {
958
968
return !!this.$attrs.onFigureClick
959
969
},
970
+ hasHeaderAriaFallback() {
971
+ return this.empty || isSlotPopulated(this.$slots.content)
972
+ },
960
973
},
961
974
962
975
watch: {
@@ -1019,7 +1032,7 @@ export default {
1019
1032
document.querySelector('#header'),
1020
1033
], {
1021
1034
allowOutsideClick: true,
1022
- fallbackFocus: this.$refs.closeButton.$el,
1035
+ fallbackFocus: this.$refs.closeButton? .$el ?? this.$refs.sidebar ,
1023
1036
trapStack: getTrapStack(),
1024
1037
escapeDeactivates: false,
1025
1038
})
@@ -1146,7 +1159,16 @@ export default {
1146
1159
* @public
1147
1160
*/
1148
1161
focus() {
1149
- (this.$refs.header ?? this.$refs.toggle)?.focus()
1162
+ if (!this.open && !this.noToggle) {
1163
+ this.$refs.toggle.$el.focus()
1164
+ return
1165
+ }
1166
+
1167
+ if (this.hasHeaderAriaFallback) {
1168
+ this.$refs.headerAriaFallback.focus()
1169
+ } else {
1170
+ this.$refs.header.focus()
1171
+ }
1150
1172
},
1151
1173
1152
1174
/**
0 commit comments