-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
There was a problem hiding this 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 forday.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> |
There was a problem hiding this comment.
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
src/datepicker/datepicker-i18n.ts
Outdated
@@ -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. |
There was a problem hiding this comment.
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
src/datepicker/datepicker-i18n.ts
Outdated
@@ -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) { |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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}`
?
Update: I played with nvda, voice over and jaws 17. Ok, except for jaws |
src/datepicker/datepicker-i18n.ts
Outdated
|
||
getDayAriaLabel(date: NgbDateStruct): string { | ||
const jsDate = new Date(date.year, date.month - 1, date.day); | ||
return this.datePipe.transform(date, 'fullDate', null, this.locale); |
There was a problem hiding this comment.
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 date
→ jsDate
An update for JAWS:
|
There was a problem hiding this 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(); |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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...
67f2763
to
c88ecf2
Compare
@fbasso, clang-format is unhappy... |
Part of #1946