Skip to content

Commit e2ef853

Browse files
mirawlinDimitri Lahaye
and
Dimitri Lahaye
authored
fix(mon-pix): move aria-live assertive to the whole Grain div
Co-authored-by: Dimitri Lahaye <[email protected]>
1 parent 96e8453 commit e2ef853

File tree

4 files changed

+2
-55
lines changed

4 files changed

+2
-55
lines changed

mon-pix/app/pods/components/module/grain/component.js

-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ export default class ModuleGrain extends Component {
3939
});
4040
}
4141

42-
get ariaLiveGrainValue() {
43-
return this.args.hasJustAppeared ? 'assertive' : null;
44-
}
45-
4642
@action
4743
focusAndScroll(element) {
4844
if (!this.args.hasJustAppeared) {

mon-pix/app/pods/components/module/grain/template.hbs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
<article
2-
class="grain {{if @hasJustAppeared 'grain--active'}}"
3-
aria-live={{this.ariaLiveGrainValue}}
4-
tabindex="-1"
5-
{{did-insert this.focusAndScroll}}
6-
>
1+
<article class="grain {{if @hasJustAppeared 'grain--active'}}" tabindex="-1" {{did-insert this.focusAndScroll}}>
72
<h2 class="screen-reader-only">{{@grain.title}}</h2>
83

94
{{#if @transition}}

mon-pix/app/pods/components/module/passage/template.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<h1>{{@module.title}}</h1>
77
</div>
88

9-
<div class="module-passage__content" {{did-insert this.setGrainScrollOffsetCssProperty}}>
9+
<div class="module-passage__content" aria-live="assertive" {{did-insert this.setGrainScrollOffsetCssProperty}}>
1010
{{#each this.grainsToDisplay as |grain index|}}
1111
<Module::Grain
1212
@grain={{grain}}

mon-pix/tests/integration/components/module/passage_test.js

-44
Original file line numberDiff line numberDiff line change
@@ -189,50 +189,6 @@ module('Integration | Component | Module | Passage', function (hooks) {
189189
assert.strictEqual(grainsAfterContinueAction.length, 2);
190190
});
191191

192-
test('should only set the aria-live="assertive" attribute on the last grain', async function (assert) {
193-
// given
194-
const store = this.owner.lookup('service:store');
195-
const text1Element = { content: 'content', type: 'text' };
196-
const text2Element = { content: 'content 2', type: 'text' };
197-
const text3Element = { content: 'content 3', type: 'text' };
198-
const grain1 = store.createRecord('grain', { elements: [text1Element] });
199-
const grain2 = store.createRecord('grain', { elements: [text2Element] });
200-
const grain3 = store.createRecord('grain', { elements: [text3Element] });
201-
202-
const module = store.createRecord('module', { title: 'Module title', grains: [grain1, grain2, grain3] });
203-
this.set('module', module);
204-
205-
const passage = store.createRecord('passage');
206-
this.set('passage', passage);
207-
208-
const screen = await render(hbs`<Module::Passage @module={{this.module}} @passage={{this.passage}} />`);
209-
210-
const grainsBeforeAnyAction = screen.getAllByRole('article');
211-
assert.strictEqual(grainsBeforeAnyAction.length, 1);
212-
const firstGrain = grainsBeforeAnyAction.at(-1);
213-
assert.strictEqual(firstGrain.getAttribute('aria-live'), null);
214-
215-
// when
216-
await clickByName(continueButtonName);
217-
218-
// then
219-
const grainsAfterOneContinueActions = screen.getAllByRole('article');
220-
assert.strictEqual(grainsAfterOneContinueActions.length, 2);
221-
const secondGrain = grainsAfterOneContinueActions.at(-1);
222-
assert.strictEqual(firstGrain.getAttribute('aria-live'), null);
223-
assert.strictEqual(secondGrain.getAttribute('aria-live'), 'assertive');
224-
225-
// when
226-
await clickByName(continueButtonName);
227-
228-
// then
229-
const grainsAfterTwoContinueActions = screen.getAllByRole('article');
230-
assert.strictEqual(grainsAfterTwoContinueActions.length, 3);
231-
const thirdGrain = grainsAfterTwoContinueActions.at(-1);
232-
assert.strictEqual(secondGrain.getAttribute('aria-live'), null);
233-
assert.strictEqual(thirdGrain.getAttribute('aria-live'), 'assertive');
234-
});
235-
236192
test('should give focus on the last grain when appearing', async function (assert) {
237193
// given
238194
const store = this.owner.lookup('service:store');

0 commit comments

Comments
 (0)