angular / angular/components

valid dd/mm format switch sides after manual input on datepicker field

Open
#11,936 18 comments 11 reactions 0 assignees View on GitHub
area: material/datepicker P4
Dominant language
TypeScript
Stars
25k
Forks
6.8k
Avg merge
1d 8h
Merged PRs (30d)
91

Description

#### Bug, feature request, or proposal:
Bug

#### What is the expected behavior?
That the valid `dd/mm/yyyy` inputed date remains as it is, not matter what, they always switch sides on change.

#### What is the current behavior?
E.g.: `03/02/1990` becomes `02/03/1990`.

#### What are the steps to reproduce?
Set a custom locale like Brasil:

```typescript
// location
import localePt from '@angular/common/locales/pt';
import localePtExtra from '@angular/common/locales/extra/pt';

registerLocaleData(localePt, 'pt', localePtExtra);
```

Then try to use the datepicker with manual input.

#### What is the use-case or motivation for changing an existing behavior?
Because it works very well with the Angular locale config, there's just this switch bug that does not work properly.

#### Which versions of Angular, Material, OS, TypeScript, browsers are affected?
```json
{
"@angular/core": "^6.0.6",
"@angular/material": "^6.3.0",
}
```

#### Is there anything else we should know?

##### UI input:

![image](https://user-images.githubusercontent.com/3942006/41925531-3ab16044-7943-11e8-884c-3b591f537b8e.png)

##### Manual input:
![image](https://user-images.githubusercontent.com/3942006/41925561-4f8d566c-7943-11e8-8a73-e2d76a0659b1.png)

~I really don't wanna use moment.js~

----

It seems like the StackBlitz example isn't wroking as well: https://stackblitz.com/angular/vnvbdjykmve?file=app%2Fdatepicker-locale-example.ts

Contributor guide

Open the contributing guide

Research direction

Start with the linked StackBlitz example at app/datepicker-locale-example.ts and reproduce the datepicker's manual-input behavior after registering the pt locale and extra locale data. Trace the datepicker's locale-aware parsing and change handling; done means an entered value such as 03/02/1990 remains the same after the field changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
frontend, internationalization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.