Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Fix datepicker no labels #1753

Merged
merged 28 commits into from
Jun 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3f4222e
Resolving Card action bar still visable after hiding with *ngIf #1421
blackbaud-conorwright Mar 7, 2018
a450054
Addressed PR style comments
blackbaud-conorwright Mar 8, 2018
4b809aa
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 9, 2018
d55f351
Merge branch 'master' into master
Blackbaud-SteveBrush Mar 9, 2018
833bcc7
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 12, 2018
b553659
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 15, 2018
ab82ba3
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 19, 2018
db21c76
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 27, 2018
a282a86
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 30, 2018
d210c2b
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Apr 10, 2018
35e789d
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Apr 17, 2018
636c5dd
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Apr 23, 2018
bdc97a6
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright May 1, 2018
6104aaf
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright May 2, 2018
37f50ec
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright May 8, 2018
76279cd
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright May 14, 2018
2324e90
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright May 16, 2018
d48b8f2
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright May 23, 2018
b2e318a
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright May 25, 2018
8d52945
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright May 25, 2018
194e01f
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Jun 6, 2018
2d5e1e4
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Jun 12, 2018
9eb6aaa
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Jun 13, 2018
11e43d5
added aria label to input directive
blackbaud-conorwright Jun 22, 2018
d17948c
set aria label on datepicker input
blackbaud-conorwright Jun 22, 2018
b7877e5
Merge remote-tracking branch 'upstream/master' into fix-datepicker-no…
blackbaud-conorwright Jun 22, 2018
697d785
added testing for new datepicker labels
blackbaud-conorwright Jun 22, 2018
27d3771
Merge remote-tracking branch 'upstream/master' into fix-datepicker-no…
blackbaud-conorwright Jun 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/locales/resources_en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
"_description": "error message shown when an invalid date is entered.",
"message": "Please enter a valid date"
},
"date_field_default_label": {
"_description": "The label for the datepicker component's input field for screen readers when the consumer has not specified a label.",
"message": "Date input field."
},
"date_range_picker_at_any_time": {
"_description": "text for date range picker",
"message": "At any time"
Expand Down
13 changes: 11 additions & 2 deletions src/modules/datepicker/datepicker-input.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import {
import {
SkyDatepickerConfigService
} from './datepicker-config.service';
import {
SkyResourcesService
} from '../resources';

// tslint:disable:no-forward-ref no-use-before-declare
const SKY_DATEPICKER_VALUE_ACCESSOR = {
Expand Down Expand Up @@ -80,13 +83,13 @@ export class SkyDatepickerInputDirective implements
public startingDay: number = 0;

private dateFormatter = new SkyDateFormatter();

private modelValue: Date;

public constructor(
private renderer: Renderer,
private elRef: ElementRef,
private config: SkyDatepickerConfigService) {
private config: SkyDatepickerConfigService,
private skyResourceSvc: SkyResourcesService) {
this.configureOptions();
}

Expand All @@ -101,6 +104,12 @@ export class SkyDatepickerInputDirective implements
this.writeValue(newDate);
this._onChange(newDate);
});
if (!this.elRef.nativeElement.getAttribute('aria-label')) {
this.renderer.setElementAttribute(
this.elRef.nativeElement,
'aria-label',
this.skyResourceSvc.getString('date_field_default_label'));
}
}

public ngOnDestroy() {
Expand Down
3 changes: 2 additions & 1 deletion src/modules/datepicker/datepicker.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

<div class="sky-input-group-btn sky-input-group-datepicker-btn">
<sky-dropdown
buttonType="calendar"
alignment="right"
aria-hidden="true"
buttonType="calendar"
[messageStream]="dropdownController">
<sky-dropdown-menu>
<sky-datepicker-calendar
Expand Down
11 changes: 11 additions & 0 deletions src/modules/datepicker/datepicker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,17 @@ describe('datepicker', () => {
.not.toBeNull();
});

it('should apply aria-label to the datepicker input when none is provided', () => {
fixture.detectChanges();
expect(nativeElement.querySelector('input').getAttribute('aria-label')).toBe('Date input field.');
});

it('should not overwrite aria-label on the datepicker input when one is provided', () => {
nativeElement.querySelector('input').setAttribute('aria-label', 'This is a date field.');
fixture.detectChanges();
expect(nativeElement.querySelector('input').getAttribute('aria-label')).toBe('This is a date field.');
});

it('should keep the calendar open on mode change', fakeAsync(() => {
fixture.detectChanges();
openDatepicker(nativeElement, fixture);
Expand Down