vmware-archive / clarity

Clarity is a scalable, accessible, customizable, open source design system built with web components. Works with any JavaScript framework, built for enterprises, and designed to be inclusive.
http://clarity.design
MIT License
6.43k stars 762 forks source link

input type="date" : The value don't show up at start #745

Closed samdidos closed 7 years ago

samdidos commented 7 years ago

First, I would like to thank and congratulate the team for your work, Clarity is a pretty cool library.

[x] bug
[ ] feature request
[ ] enhancement

Expected behavior

I have an object with an existing date attribute in it, and I want it to be modified

<input type="date" name="dateToModify" [(ngModel)]="myObject.date">

I expect to show the actual date value and let me change it with the date picker.

Actual behavior

When a value already exists, the value don't appear in the input field. It only appears once I set it.

Reproduction of behavior

Jinnie commented 7 years ago

Hi @samdidos, This is an Angular2 issue, not Clarity related. Many reports can be found on the topic. The cleanest and easiest solution I've seen so far is to change the binding like this:

    `<input type="date"  [ngModel]="myDate | date:'yyyy-MM-dd'" 
                 (ngModelChange)="myDate = $event">`

Otherwise you have to manually parse the date you want to preset to the yyyy-MM-dd format, as the Angular component only recognises this format, not the generic Date object.

youdz commented 7 years ago

Thanks @Jinnie For answering this. 😄

samdidos commented 7 years ago

@Jinnie Thank you for the tip!

samdidos commented 7 years ago

It works, thanks a lot! Can you help me on another similar matter? I would like the Clarity date picker to show the date in format "dd/mm/yyyy" instead of the default format "mm/dd/yyyy", is that possible?

mathisscott commented 7 years ago

@samdidos : There is no datepicker component in Clarity (yet). See #474

What you are likely seeing is the built-in Chrome datepicker that is tied to the date inputs.

See MDN article for more info on that

samdidos commented 7 years ago

Ok thx a lot @mathisscott I haven't realised that!

jatinpatel136 commented 6 years ago

@Jinnie Thanks alot!

ganesh190589 commented 4 years ago

Try this. Working fine <input type="date" class="form-control" name="startDate" value="{{admissionDetail.startDate | date:'yyyy-MM-dd'}}" formControlName="startDate" [(ngModel)]="admissionDetail.startDate">

github-actions[bot] commented 4 years ago

Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.