Skip to content

Datepicker set value updates text even if value doesn't change #6333

@james-schwartzkopf

Description

@james-schwartzkopf

Bug, feature request, or proposal:

What is the expected behavior?

Only update the input text if the value passed to the setter has changed.

What is the current behavior?

The text of the input is always set to the formatted version of the value.

What are the steps to reproduce?

http://plnkr.co/edit/kaS3PvvuSmn0leykKy2D?p=preview

Try to enter a date by typing (typing a '0' will instantly change to 1/1/2000

What is the use-case or motivation for changing an existing behavior?

The plunker above implements what I understand to be a common pattern with using ngrx/store with reactive forms.

The FormGroup valueChanges emitter is used to keep the store updated with the users changes.

FormGroup setValue is used to keep the form synced with the store (so changes in the store besides those created by valueChanges will be also be reflected in the form).

I think this could be fixed by moving the renderer.setProperty call to inside the sameDate check in the MdDatepickerInput value property setter.

If so, it would probably also make sense to add some code to the blur event to format and set the inputs text so the value displayed in the input after the user leaves the field is the canonical form of the date (zero padding, separators, etc).

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

beta-8

Is there anything else we should know?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2The issue is important to a large percentage of users, with a workaroundarea: material/datepicker

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions