From 177d055ea6291e52be422d18a721267c678d2e97 Mon Sep 17 00:00:00 2001 From: Adrien Le Gall Date: Tue, 2 Jul 2024 10:54:40 +0200 Subject: [PATCH] fix: add ariaLabelledBy attribute --- ember-amount-input/src/components/amount-input.hbs | 1 + ember-amount-input/src/components/amount-input.ts | 5 +++++ .../integration/components/amount-input/component-test.ts | 4 +++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ember-amount-input/src/components/amount-input.hbs b/ember-amount-input/src/components/amount-input.hbs index 1616a44f..01590fa8 100644 --- a/ember-amount-input/src/components/amount-input.hbs +++ b/ember-amount-input/src/components/amount-input.hbs @@ -14,6 +14,7 @@ placeholder={{this.placeholder}} disabled={{@disabled}} readonly={{@readonly}} + aria-labelledby={{@ariaLabelledBy}} {{on 'keydown' this.onKeyDown}} {{on 'input' this.onInput}} {{on 'paste' this.onPaste}} diff --git a/ember-amount-input/src/components/amount-input.ts b/ember-amount-input/src/components/amount-input.ts index b31499f0..f04429a1 100644 --- a/ember-amount-input/src/components/amount-input.ts +++ b/ember-amount-input/src/components/amount-input.ts @@ -7,6 +7,11 @@ const KEY_FULLSTOP = '.'; const KEY_COMMA = ','; export interface AmountInputArgs { + /** + * The arial label for the input + */ + ariaLabelledBy?: string; + /** * The currency displayed in the input */ diff --git a/test-app/tests/integration/components/amount-input/component-test.ts b/test-app/tests/integration/components/amount-input/component-test.ts index 9a8485d1..c4c83723 100644 --- a/test-app/tests/integration/components/amount-input/component-test.ts +++ b/test-app/tests/integration/components/amount-input/component-test.ts @@ -44,7 +44,8 @@ module('Integration | Component | amount-input', function (hooks) { @value={{this.value}} @min={{5}} @max={{10}} - @update={{fn (mut this.value)}} /> + @update={{fn (mut this.value)}} + @ariaLabelledBy="foo" /> `); assert.dom('.amount-input__currency').hasText('USD'); @@ -59,6 +60,7 @@ module('Integration | Component | amount-input', function (hooks) { assert.dom('input').hasAttribute('placeholder', '1.000.000'); assert.dom('input').hasAttribute('min', '5'); assert.dom('input').hasAttribute('max', '10'); + assert.dom('input').hasAttribute('aria-labelledby', 'foo'); }); test('uses named property declared (even if undefined) instead of defaults', async function (this: TestContext, assert) {