Skip to content

Commit 8d7558b

Browse files
authored
Enable screen readers to skip 'main' in IDE mode (#658) rdar://107573378
* skip 'main' in IDE mode, since main is the only content rdar://107573378 skip 'main' in IDE mode, since main is the only content
1 parent 917c5a1 commit 8d7558b

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/components/DocumentationTopic.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
class="doc-topic"
1414
:class="{ 'with-on-this-page': enableOnThisPageNav && isOnThisPageNavVisible }"
1515
>
16-
<main class="main" id="main" role="main" tabindex="0">
16+
<component
17+
:is="isTargetIDE ? 'div' : 'main'"
18+
class="main" id="main"
19+
>
1720
<DocumentationHero
1821
:role="role"
1922
:enhanceBackground="enhanceBackground"
@@ -135,7 +138,7 @@
135138
</template>
136139
</div>
137140
<BetaLegalText v-if="!isTargetIDE && hasBetaContent" />
138-
</main>
141+
</component>
139142
<div aria-live="polite" class="visuallyhidden">
140143
{{ $t('documentation.current-page', { title: pageTitle }) }}
141144
</div>

tests/unit/components/DocumentationTopic.spec.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ describe('DocumentationTopic', () => {
165165
wrapper = shallowMount(DocumentationTopic, {
166166
propsData,
167167
provide: {
168+
isTargetIDE: false,
168169
store: {
169170
state: { onThisPageSections: [], references: {} },
170171
reset: jest.fn(),
@@ -219,13 +220,29 @@ describe('DocumentationTopic', () => {
219220
expect(wrapper.is('div.doc-topic')).toBe(true);
220221
});
221222

222-
it('renders a <main>', () => {
223+
it('renders a <main> in non-IDE mode', () => {
223224
const main = wrapper.find('main');
224225
expect(main.exists()).toBe(true);
225226
expect(main.classes('main')).toBe(true);
226227
expect(main.attributes('id')).toBe('main');
227-
expect(main.attributes('role')).toBe('main');
228-
expect(main.attributes('tabindex')).toBe('0');
228+
});
229+
230+
it('renders a <div> instead of <main> in IDE mode', () => {
231+
wrapper = shallowMount(DocumentationTopic, {
232+
propsData,
233+
provide: {
234+
isTargetIDE: true,
235+
store: {
236+
state: { onThisPageSections: [], references: {} },
237+
reset: jest.fn(),
238+
},
239+
},
240+
});
241+
242+
expect(wrapper.find('main').exists()).toBe(false);
243+
const div = wrapper.find('.main');
244+
expect(div.exists()).toBe(true);
245+
expect(div.attributes('id')).toBe('main');
229246
});
230247

231248
it('renders an aria live that tells VO users which it is the current page content', () => {

0 commit comments

Comments
 (0)