-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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): wire up selected value propagation #3330
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.
Nits, but needs tests for using with form directives like ngModel or formControl.
private _value: SimpleDate; | ||
|
||
// Implemented as part of ControlValueAccessor | ||
writeValue(value: SimpleDate) { |
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.
Return types
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 guess... I don't see much value in the : void
} | ||
set value(value: any) { | ||
this._value = this._locale.parseDate(value); | ||
let stringValue = this._value == null ? '' : this._locale.formatDate(this._value); |
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.
Nit: const?
src/lib/datepicker/index.ts
Outdated
], | ||
exports: [ | ||
MdCalendar, | ||
MdCalendarTable, |
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.
Do you intend for the CalendarTable, MonthView, etc. to be used externally? Seems like you can remove them from the exports list.
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.
LGTM
} | ||
|
||
@Input() | ||
get value() { |
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.
nit: return type?
addressed comments, PTAL |
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.
Requesting a few more tests
|
||
ngAfterContentInit() { | ||
if (this._datepicker) { | ||
this._datepicker.selectedChanged.subscribe((selected: SimpleDate) => { |
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.
Do you unsubscribe from this anywhere?
|
||
@Component({ | ||
template: ` | ||
<input [mdDatepicker]="d" [value]="'1/1/2020'"> |
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.
Nit: might be easier to scan if it's just value="1/1/2020"
|
||
expect(testComponent.selected).toEqual(selected); | ||
expect(testComponent.datepickerInput.value).toEqual(selected); | ||
})); |
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.
We should add tests that ensure that touched, disabled, and dirty still work, given that we're re-implementing them in the value accessor
comments addressed |
testComponent.datepicker.selected = new SimpleDate(2017, 0, 1); | ||
detectModelChanges(fixture); | ||
|
||
expect(inputEl.classList).toContain('ng-dirty'); |
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 should actually not mark the control dirty based on programmatic changes. Dirtiness is a reflection of UI changes only (what the user does). We're probably calling the change callback somewhere we shouldn't be.
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.
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.
LGTM
* enable value propagation through various components & directives * add tests * fix lint * addressed comments * addressed feedback * fix lint * make datepicker selected property internal * add test for pristine after ngModel change
* enable value propagation through various components & directives * add tests * fix lint * addressed comments * addressed feedback * fix lint * make datepicker selected property internal * add test for pristine after ngModel change
* enable value propagation through various components & directives * add tests * fix lint * addressed comments * addressed feedback * fix lint * make datepicker selected property internal * add test for pristine after ngModel change
* enable value propagation through various components & directives * add tests * fix lint * addressed comments * addressed feedback * fix lint * make datepicker selected property internal * add test for pristine after ngModel change
* enable value propagation through various components & directives * add tests * fix lint * addressed comments * addressed feedback * fix lint * make datepicker selected property internal * add test for pristine after ngModel change
* enable value propagation through various components & directives * add tests * fix lint * addressed comments * addressed feedback * fix lint * make datepicker selected property internal * add test for pristine after ngModel change
* enable value propagation through various components & directives * add tests * fix lint * addressed comments * addressed feedback * fix lint * make datepicker selected property internal * add test for pristine after ngModel change
* enable value propagation through various components & directives * add tests * fix lint * addressed comments * addressed feedback * fix lint * make datepicker selected property internal * add test for pristine after ngModel change
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. |
as of this PR we have a bare minimum working datepicker \o/