Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(datepicker): aria-label added on days #2319

Merged
merged 1 commit into from
Apr 27, 2018

Conversation

fbasso
Copy link
Member

@fbasso fbasso commented Apr 16, 2018

Part of #1946

Copy link
Member

@maxokorokov maxokorokov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good. A couple of comments:

  • some tests are failing on Travis CI
  • could you please update datpicker-service.spec.ts with a couple of unit tests for day.ariaLabel generation?
  • which screen readers have you tested it with?

@@ -30,16 +30,16 @@ import {DEMO_SNIPPETS} from './demos';
<ngbd-datepicker-disabled></ngbd-datepicker-disabled>
</ngbd-example-box>
<ngbd-example-box demoTitle="Custom date adapter" [snippets]="snippets" component="datepicker" demo="adapter">
<ngbd-datepicker-adapter></ngbd-datepicker-adapter>
<ngbd-datepicker-adapter></ngbd-datepicker-adapter>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please revert changes to datepicker.component.ts, you removed spaces here

@@ -26,6 +28,12 @@ export abstract class NgbDatepickerI18n {
* With default calendar we use ISO 8601: 'month' is 1=January ... 12=December
*/
abstract getMonthFullName(month: number): string;

/**
* Returns the full month name to display in the date picker navigation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to update the comment for getDayAriaLabel

@@ -34,7 +42,7 @@ export class NgbDatepickerI18nDefault extends NgbDatepickerI18n {
private _monthsShort: Array<string>;
private _monthsFull: Array<string>;

constructor(@Inject(LOCALE_ID) locale: string) {
constructor(@Inject(LOCALE_ID) private locale: string, private datePipe: DatePipe) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be _locale and _datePipe as they're private according to repo style guide...

@@ -24,6 +24,10 @@ export class IslamicI18n extends NgbDatepickerI18n {
getMonthFullName(month: number) {
return this.getMonthShortName(month);
}

getDayAriaLabel(date: NgbDateStruct): string {
return new Date(date.year, date.month - 1, date.day).toString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an alternative maybe just `${date.day}-${date.month}-${date.year}`?

@maxokorokov
Copy link
Member

Update: I played with nvda, voice over and jaws 17. Ok, except for jaws
With jaws 17 I have navigation with arrow keys between days that doesn't work at all: Chrome, Win 7

@maxokorokov maxokorokov added this to the 2.1.0 milestone Apr 18, 2018

getDayAriaLabel(date: NgbDateStruct): string {
const jsDate = new Date(date.year, date.month - 1, date.day);
return this.datePipe.transform(date, 'fullDate', null, this.locale);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like you have a bug here datejsDate

@maxokorokov
Copy link
Member

An update for JAWS:
JAWS 18 → everything works for me
JAWS 17:

  • navigation with arrow keys doesn't work without role=application
  • with role=application it says not in the table when trying to read a div with role=gridcell

Copy link
Member

@maxokorokov maxokorokov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, LGTM, but tests are still incomplete...

@@ -33,6 +33,10 @@ export class CustomDatepickerI18n extends NgbDatepickerI18n {
getMonthFullName(month: number): string {
return this.getMonthShortName(month);
}

getDayAriaLabel(date: NgbDateStruct): string {
return new Date(date.year, date.month - 1, date.day).toString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed this one → ${date.day}-${date.month}-${date.year}

@@ -33,13 +33,13 @@ import {DEMO_SNIPPETS} from './demos';
<ngbd-datepicker-adapter></ngbd-datepicker-adapter>
</ngbd-example-box>
<ngbd-example-box demoTitle="Internationalization of datepickers" [snippets]="snippets" component="datepicker" demo="i18n">
<ngbd-datepicker-i18n></ngbd-datepicker-i18n>
<ngbd-datepicker-i18n></ngbd-datepicker-i18n>
Copy link
Member

@maxokorokov maxokorokov Apr 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you revert all changes in this file please, as they just break formatting?

@@ -120,6 +123,8 @@ export function buildMonth(calendar: NgbCalendar, date: NgbDate, state: Datepick
const newDate = new NgbDate(date.year, date.month, date.day);
const nextDate = calendar.getNext(newDate);

const ariaLabel = i18n.getDayAriaLabel(newDate);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I mentioned in the previous review, could you please add a couple of tests to the detepicker-service.spec.ts that will test that labels on the days?

You would have caught unused jsDate bug the service if you had one...

@fbasso fbasso force-pushed the datepicker_aria branch 2 times, most recently from 67f2763 to c88ecf2 Compare April 24, 2018 12:27
@maxokorokov maxokorokov modified the milestones: 2.1.0, 2.0.0 Apr 24, 2018
@maxokorokov
Copy link
Member

@fbasso, clang-format is unhappy...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants