Skip to content

Conversation

mnahkies
Copy link
Contributor

  • add ng-content to datepicker header to simplify
    customization of this component
  • fix tests using calendarHeaderComponent property
    to correctly reference the custom component
  • add test to prove that custom component was
    rendered

Closes #13212

- add ng-content to datepicker header to simplify
  customization of this component
- fix tests using calendarHeaderComponent property
  to correctly reference the custom component
- add test to prove that custom component was
  rendered

Closes angular#13212
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Sep 21, 2018
<mat-calendar-header #header>
<button mat-button type="button" class="mat-calendar-today-button"
(click)="todayClicked()" [attr.aria-label]="todayButtonLabel"
cdkAriaLive="polite">
Copy link
Member

Choose a reason for hiding this comment

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

The button shouldn't have cdkAriaLive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I remove attr.aria-label as well? To be honest I was just following suit based on the buttons in mat-calendar-header

(https://github.com/angular/material2/blob/master/src/lib/datepicker/calendar-header.html#L4-L5)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've gone ahead and removed it for brevity

}));
});

describe('datepicker with custom header using ng-content', () => {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure whether we need a test for this. It's basically testing if ng-content works which isn't something Material is responsible for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with this comment for the datepicker with custom header using ng-content suite I added and will remove.

However I think the additional test that checks that the custom element is added is useful for the datepicker with custom header suite. Prior to my change to DatepickerWithCustomHeader a custom header component was not in fact being used by that test suite.

- remove unnecessary tests
- simplify demo code
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

LGTM

@crisbeto crisbeto added pr: lgtm action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release labels Sep 22, 2018
@jelbourn jelbourn removed the action: merge The PR is ready for merge by the caretaker label Sep 26, 2018
@jelbourn
Copy link
Member

jelbourn commented Sep 26, 2018

I'd like @mmalerba to weigh in on this

I'm a little iffy about projecting all of the content.

@mmalerba
Copy link
Contributor

I think this should be fine, we won't project anything in the default case, but if people are using the MatCalendarHeader to build a custom header it gives them a way to add some additional content.

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Sep 26, 2018
@vivian-hu-zz vivian-hu-zz merged commit 3fc0d36 into angular:master Oct 5, 2018
roboshoes pushed a commit to roboshoes/material2 that referenced this pull request Oct 23, 2018
* feat(datepicker): add ng-content to datepicker header

- add ng-content to datepicker header to simplify
  customization of this component
- fix tests using calendarHeaderComponent property
  to correctly reference the custom component
- add test to prove that custom component was
  rendered

Closes angular#13212

* test(datepicker): code review fixes

- remove unnecessary tests
- simplify demo code
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
@mnahkies mnahkies deleted the feat-13212-add-ng-content-to-datepicker-header branch September 10, 2019 07:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mat-datepicker] proposal: pull request to add option to display a today button in header
6 participants