-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(material/datepicker): Add aria-current="date" to current date #23714
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(material/datepicker): Add aria-current="date" to current date #23714
Conversation
I am reasonably certain that the unit test added here for this functionality could be better but am not quite certain of the best way forward. Right now it checks that the If there are thoughts around how to do this better please let me know! |
521de2a
to
887012c
Compare
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 for the PR!
@@ -55,6 +55,13 @@ describe('MatCalendarBody', () => { | |||
expect(todayCell.innerHTML.trim()).toBe('3'); | |||
}); | |||
|
|||
it('sets aria-current="date" on today', () => { | |||
const todayCell = calendarBodyNativeElement.querySelector( |
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.
I would also test:
- When today is in the active month, that there's exactly one cell with
aria-current
- When today is not in the active month, that there's exactly zero cells with
aria-current
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.
Interestingly enough:
todayValue
in MatCalendarBody
is a number
. Its value is passed in from MatMonthView
with !
non-null assertion. In MatMonthView
, today not being within the month is represented by this value being null
.
I can replicate this setup in testing by simply setting the testing component's today
value to be number|null
. I'm going to do that here, but if it makes sense would it be fine by you to retype MatCalendarBody
's todayValue
@Input
from number
to number|null
? Right now we're explicitly passing null
in via non-null assertion which feels a bit unfortunate.
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.
Mea culpa:
todayValue
is taken via _dateAdapter.today()
converted to a number
via _getCellCompareValue
. This function generates a new Date
object via the year, month, and day from the passed in DateAdapter
. DateAdapter
does not allow null
to be returned from this method, so I was incorrect.
I'll update the tests to work utilize a timestamp outside the specified month (which I probably should have done to begin with).
0e3af66
to
173d480
Compare
Caretaker note: this should be a fix |
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.
Looks good, just one last nit
const todayCell = todayCells[0]; | ||
|
||
expect(todayCell).not.toBeNull(); | ||
expect(todayCell.innerHTML.trim()).toBe('3'); |
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.
Prefer textContent
here to innerHTML
(similar for other tests)
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.
Sorry about the delay getting back to this! This issue should be resolved now.
3605274
to
60cffce
Compare
60cffce
to
9889151
Compare
9889151
to
1e815ac
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Closes #23713