mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ACS-10247] a11y fix: SR announces Start/End Date fields incorrectly in date popup (#11592)
* [ACS-10247] a11y fix: SR announces Start/End Date fields incorrectly in date popup * fix
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@
|
|||||||
id="adf-search-date-range-between-range-label">
|
id="adf-search-date-range-between-range-label">
|
||||||
{{ 'SEARCH.DATE_RANGE_ADVANCED.BETWEEN_PLACEHOLDERS.DATE_RANGE' | translate }}
|
{{ 'SEARCH.DATE_RANGE_ADVANCED.BETWEEN_PLACEHOLDERS.DATE_RANGE' | translate }}
|
||||||
</mat-label>
|
</mat-label>
|
||||||
<mat-date-range-input [rangePicker]="$any(picker)" [max]="convertedMaxDate">
|
<mat-date-range-input [rangePicker]="$any(picker)" [max]="convertedMaxDate" #adfDateRangeInput>
|
||||||
<input
|
<input
|
||||||
matStartDate placeholder="{{ 'SEARCH.DATE_RANGE_ADVANCED.BETWEEN_PLACEHOLDERS.START_DATE' | translate }}"
|
matStartDate placeholder="{{ 'SEARCH.DATE_RANGE_ADVANCED.BETWEEN_PLACEHOLDERS.START_DATE' | translate }}"
|
||||||
data-automation-id="date-range-between-start-input"
|
data-automation-id="date-range-between-start-input"
|
||||||
|
|||||||
+15
@@ -314,4 +314,19 @@ describe('SearchDateRangeComponent', () => {
|
|||||||
expect(component.form.controls.betweenEndDate.value).toBeNull();
|
expect(component.form.controls.betweenEndDate.value).toBeNull();
|
||||||
expect(component.reset).toHaveBeenCalled();
|
expect(component.reset).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should set aria-haspopup="false" on date range inputs', () => {
|
||||||
|
const inputEls: NodeListOf<HTMLInputElement> = component.dateRangeInput.nativeElement.querySelectorAll('input');
|
||||||
|
|
||||||
|
inputEls.forEach((input) => {
|
||||||
|
spyOn(input, 'setAttribute').and.callThrough();
|
||||||
|
});
|
||||||
|
|
||||||
|
component.ngAfterViewInit();
|
||||||
|
|
||||||
|
inputEls.forEach((input) => {
|
||||||
|
expect(input.setAttribute).toHaveBeenCalledWith('aria-haspopup', 'false');
|
||||||
|
expect(input.getAttribute('aria-haspopup')).toBe('false');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+25
-2
@@ -15,7 +15,21 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, DestroyRef, effect, EventEmitter, inject, Inject, Input, OnInit, Output, ViewEncapsulation } from '@angular/core';
|
import {
|
||||||
|
AfterViewInit,
|
||||||
|
Component,
|
||||||
|
DestroyRef,
|
||||||
|
effect,
|
||||||
|
ElementRef,
|
||||||
|
EventEmitter,
|
||||||
|
inject,
|
||||||
|
Inject,
|
||||||
|
Input,
|
||||||
|
OnInit,
|
||||||
|
Output,
|
||||||
|
ViewChild,
|
||||||
|
ViewEncapsulation
|
||||||
|
} from '@angular/core';
|
||||||
import { endOfDay, isAfter, isBefore, isValid, parse } from 'date-fns';
|
import { endOfDay, isAfter, isBefore, isValid, parse } from 'date-fns';
|
||||||
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatDateFormats } from '@angular/material/core';
|
import { DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE, MatDateFormats } from '@angular/material/core';
|
||||||
import { DateFnsAdapter, MAT_DATE_FNS_FORMATS } from '@angular/material-date-fns-adapter';
|
import { DateFnsAdapter, MAT_DATE_FNS_FORMATS } from '@angular/material-date-fns-adapter';
|
||||||
@@ -57,7 +71,7 @@ const DEFAULT_DATE_DISPLAY_FORMAT = 'dd-MMM-yy';
|
|||||||
encapsulation: ViewEncapsulation.None,
|
encapsulation: ViewEncapsulation.None,
|
||||||
host: { class: 'adf-search-date-range' }
|
host: { class: 'adf-search-date-range' }
|
||||||
})
|
})
|
||||||
export class SearchDateRangeComponent implements OnInit {
|
export class SearchDateRangeComponent implements OnInit, AfterViewInit {
|
||||||
@Input()
|
@Input()
|
||||||
dateFormat = DEFAULT_DATE_DISPLAY_FORMAT;
|
dateFormat = DEFAULT_DATE_DISPLAY_FORMAT;
|
||||||
@Input()
|
@Input()
|
||||||
@@ -79,6 +93,8 @@ export class SearchDateRangeComponent implements OnInit {
|
|||||||
@Output()
|
@Output()
|
||||||
valid = new EventEmitter<boolean>();
|
valid = new EventEmitter<boolean>();
|
||||||
|
|
||||||
|
@ViewChild('adfDateRangeInput', { static: false, read: ElementRef }) dateRangeInput: ElementRef;
|
||||||
|
|
||||||
private readonly formBuilder = inject(FormBuilder);
|
private readonly formBuilder = inject(FormBuilder);
|
||||||
|
|
||||||
form = this.formBuilder.group<SearchDateRange>({
|
form = this.formBuilder.group<SearchDateRange>({
|
||||||
@@ -127,6 +143,13 @@ export class SearchDateRangeComponent implements OnInit {
|
|||||||
this.form.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.onChange());
|
this.form.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.onChange());
|
||||||
this.onReset$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.reset());
|
this.onReset$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.reset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngAfterViewInit() {
|
||||||
|
this.dateRangeInput.nativeElement.querySelectorAll('input').forEach((input: HTMLInputElement) => {
|
||||||
|
input.setAttribute('aria-haspopup', 'false');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private updateValidators(dateRangeType: DateRangeType) {
|
private updateValidators(dateRangeType: DateRangeType) {
|
||||||
switch (dateRangeType) {
|
switch (dateRangeType) {
|
||||||
case DateRangeType.BETWEEN:
|
case DateRangeType.BETWEEN:
|
||||||
|
|||||||
Reference in New Issue
Block a user