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

fix(datepicker): calendar should update when input changes #3824

Merged
merged 6 commits into from
Apr 11, 2017

Conversation

mmalerba
Copy link
Contributor

No description provided.

@mmalerba mmalerba requested a review from kara March 28, 2017 21:31
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Mar 28, 2017
@@ -116,7 +111,7 @@ export class MdDatepicker implements OnDestroy {

constructor(private _dialog: MdDialog, private _overlay: Overlay,
private _viewContainerRef: ViewContainerRef, private _locale: CalendarLocale,
@Optional() private _dir: Dir) {}
private _changeDetectorRef: ChangeDetectorRef, @Optional() private _dir: Dir) {}
Copy link
Contributor

@kara kara Apr 10, 2017

Choose a reason for hiding this comment

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

Are you using this _changeDetectorRef anywhere? Couldn't find it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope, must've been leftover from previous iteration

@@ -134,6 +139,7 @@ export class MdDatepicker implements OnDestroy {
throw new MdError('An MdDatepicker can only be associated with a single input.');
}
this._datepickerInput = input;
this._datepickerInput.valueChange.subscribe((value: SimpleDate) => this._selected = value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you unsubscribing anywhere?

this._renderer.setElementProperty(this._elementRef.nativeElement, 'value',
date ? this._locale.formatDate(date) : '');
if (!SimpleDate.equals(oldDate, date)) {
this._valueChangeEmitter.emit(date);
Copy link
Contributor

Choose a reason for hiding this comment

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

If you had something like this:

<input [value]="val" (valueChange)="doSomething()" [mdDatepicker]="dp">

Would setting the value programmatically fire the doSomething() method? It looks like valueChange is emitted in both directions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, isn't that what we want? Otherwise if I set the value programmatically the calendar won't be updated to reflect the change in the input

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I see how it's solving that problem. Just concerned that users will be confused because typically when you have a model to view change, you don't expect the view to model handler to fire as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I admit its a little weird and I had to add that equals check to stop it from infinite looping, maybe we can talk about if there's a better way

@kara kara assigned mmalerba and unassigned kara Apr 10, 2017
@mmalerba mmalerba assigned kara and unassigned mmalerba Apr 10, 2017
@@ -123,6 +121,19 @@ export class MdDatepicker implements OnDestroy {
if (this._popupRef) {
this._popupRef.dispose();
}
if (this._inputSubscription) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to unsubscribe here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry... i'm an idiot ><

Copy link
Contributor

Choose a reason for hiding this comment

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

hehe, I was a bit confused

@kara kara assigned mmalerba and unassigned kara Apr 11, 2017
Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

LGTM

@mmalerba mmalerba merged commit 23d1417 into angular:datepicker Apr 11, 2017
mmalerba added a commit that referenced this pull request Apr 14, 2017
* fix(datepicker): calendar selected date should change when input changes

* startAt fix

* fix tests

* address comments

* fix unsubscribe

* make valueChange on datepicker-input internal
mmalerba added a commit that referenced this pull request Apr 20, 2017
* fix(datepicker): calendar selected date should change when input changes

* startAt fix

* fix tests

* address comments

* fix unsubscribe

* make valueChange on datepicker-input internal
mmalerba added a commit that referenced this pull request Apr 29, 2017
* fix(datepicker): calendar selected date should change when input changes

* startAt fix

* fix tests

* address comments

* fix unsubscribe

* make valueChange on datepicker-input internal
mmalerba added a commit that referenced this pull request May 5, 2017
* fix(datepicker): calendar selected date should change when input changes

* startAt fix

* fix tests

* address comments

* fix unsubscribe

* make valueChange on datepicker-input internal
mmalerba added a commit that referenced this pull request May 9, 2017
* fix(datepicker): calendar selected date should change when input changes

* startAt fix

* fix tests

* address comments

* fix unsubscribe

* make valueChange on datepicker-input internal
@mmalerba mmalerba deleted the dp3 branch April 3, 2018 15:17
@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 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants