diff --git a/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-suggestions/org-unit-input-suggestions.component.html b/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-suggestions/org-unit-input-suggestions.component.html index 45a4dc9bb3a..6f7e7de0148 100644 --- a/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-suggestions/org-unit-input-suggestions.component.html +++ b/src/app/entity-groups/research-entities/submission/item-list-elements/org-unit/org-unit-suggestions/org-unit-input-suggestions.component.html @@ -3,7 +3,9 @@ (keydown.arrowdown)="shiftFocusDown($event)" (keydown.arrowup)="shiftFocusUp($event)" (keydown.esc)="close()" (dsClickOutside)="close();"> + + + + { expect(comp).toBeTruthy(); }); + describe('the accessible name of the suggestion input', () => { + beforeEach(() => { + comp.name = 'author'; + comp.placeholder = 'Search for an author'; + fixture.detectChanges(); + }); + + it('should label the input with a label that resolves to it', () => { + const input: HTMLInputElement = el.querySelector('input.suggestion_input'); + const label: HTMLLabelElement = el.querySelector('label'); + + expect(input.id).toBeTruthy(); + expect(label).toBeTruthy(); + // a placeholder is not a label: the association has to be real + expect(label.htmlFor).toEqual(input.id); + expect(label.textContent.trim()).toEqual('Search for an author'); + // and the label must not be rendered visibly (Bootstrap 5 dropped the old screen-reader class) + expect(Array.from(label.classList)).toContain('visually-hidden'); + }); + + it('should derive the id from the name input so two instances do not collide', () => { + const input: HTMLInputElement = el.querySelector('input.suggestion_input'); + const firstId: string = input.id; + + comp.name = 'subject'; + fixture.detectChanges(); + const label: HTMLLabelElement = el.querySelector('label'); + + expect(input.id).not.toEqual(firstId); + expect(label.htmlFor).toEqual(input.id); + }); + }); + describe('when the input field is in focus', () => { beforeEach(() => { diff --git a/src/app/shared/input-suggestions/validation-suggestions/validation-suggestions.component.html b/src/app/shared/input-suggestions/validation-suggestions/validation-suggestions.component.html index f0867ad8744..fc54140203d 100644 --- a/src/app/shared/input-suggestions/validation-suggestions/validation-suggestions.component.html +++ b/src/app/shared/input-suggestions/validation-suggestions/validation-suggestions.component.html @@ -3,7 +3,9 @@ (keydown.arrowdown)="shiftFocusDown($event)" (keydown.arrowup)="shiftFocusUp($event)" (keydown.esc)="close()" (dsClickOutside)="checkIfValidInput(form);close();"> - {{placeholder}} + {{'submission.workflow.tasks.claimed.reject.reason.title {{'submission.workflow.tasks.claimed.reject.reason.info' | translate}}