Fix/input stepper a11y: add component label to aria-label of increase and decrease buttons (#2618)

* [lion-input-stepper]: add label to the aria-label of increment and decrement buttons

* [lion-input-stepper]: update unit tests

* add changeset
This commit is contained in:
Vladimir Skorokhod 2025-11-13 14:35:44 +01:00 committed by GitHub
parent 9105f50ef3
commit b64f520680
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 24 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'@lion/ui': patch
---
[lion-input-stepper]: add component label to aria-label of increase and decrease buttons

View file

@ -383,7 +383,7 @@ export class LionInputStepper extends LocalizeMixin(LionInput) {
@focus=${this._onEnterButton} @focus=${this._onEnterButton}
@blur=${this._onLeaveButton} @blur=${this._onLeaveButton}
type="button" type="button"
aria-label="${this.msgLit('lion-input-stepper:decrease')}" aria-label="${this.msgLit('lion-input-stepper:decrease')} ${this.fieldName}"
> >
${this._decrementorSignTemplate()} ${this._decrementorSignTemplate()}
</button> </button>
@ -403,7 +403,7 @@ export class LionInputStepper extends LocalizeMixin(LionInput) {
@focus=${this._onEnterButton} @focus=${this._onEnterButton}
@blur=${this._onLeaveButton} @blur=${this._onLeaveButton}
type="button" type="button"
aria-label="${this.msgLit('lion-input-stepper:increase')}" aria-label="${this.msgLit('lion-input-stepper:increase')} ${this.fieldName}"
> >
${this._incrementorSignTemplate()} ${this._incrementorSignTemplate()}
</button> </button>

View file

@ -17,6 +17,7 @@ const inputStepperWithAttrs = html`<lion-input-stepper
step="10" step="10"
min="100" min="100"
max="200" max="200"
label="Label"
></lion-input-stepper>`; ></lion-input-stepper>`;
describe('<lion-input-stepper>', () => { describe('<lion-input-stepper>', () => {
@ -473,5 +474,21 @@ describe('<lion-input-stepper>', () => {
incrementButton?.dispatchEvent(new Event('blur')); incrementButton?.dispatchEvent(new Event('blur'));
expect(stepperValue?.hasAttribute('aria-live')).to.be.false; expect(stepperValue?.hasAttribute('aria-live')).to.be.false;
}); });
it('decrease button should have aria-label with the component label', async () => {
const el = await fixture(inputStepperWithAttrs);
const decrementButton = el.querySelector('[slot=prefix]');
expect(decrementButton?.hasAttribute('aria-label')).to.be.true;
expect(decrementButton?.getAttribute('aria-label')).to.equal('Decrease Label');
});
it('increase button should have aria-label with the component label', async () => {
const el = await fixture(inputStepperWithAttrs);
const incrementButton = el.querySelector('[slot=suffix]');
expect(incrementButton?.hasAttribute('aria-label')).to.be.true;
expect(incrementButton?.getAttribute('aria-label')).to.equal('Increase Label');
});
}); });
}); });