-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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(material/datepicker): add ability to have numeric zero value in input #24813
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). For more information, open the CLA check for this pull request. |
Hello @diprokon , this seems reasonable, but you could add a unit test please? |
? this._dateAdapter.format(value, this._dateFormats.display.dateInput) | ||
: ''; | ||
this._elementRef.nativeElement.value = | ||
value != null ? this._dateAdapter.format(value, this._dateFormats.display.dateInput) : ''; |
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.
Wouldn't think also try to format other falsy values like an empty string?
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.
Yep, it's already there. '!= null' checks only for 'null' and 'undefined'. 0, "", false, etc. will be formatted
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 think @crisbeto is saying that maybe ''
should be treated like null
. I think it is technically correct to try to parse it though. We don't know what the generic type D
will be, but it could be string
. If its not string
people shouldn't really be passing ''
anyways. I think we can keep it like this and try to presubmit it in Google. If we find a lot of people using ''
to mean null
we may want to change it
…nput Shows valid formatted value for 'falsy' values (exp 0) Custom DateAdapter (exp TimestampDateAdapter) can have valid numeric 0 value (for timestamp it is 1/1/1970), but datepicker input doesn't show formatted value
@zarend can you check the tests, please? |
? this._dateAdapter.format(value, this._dateFormats.display.dateInput) | ||
: ''; | ||
this._elementRef.nativeElement.value = | ||
value != null ? this._dateAdapter.format(value, this._dateFormats.display.dateInput) : ''; |
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 think @crisbeto is saying that maybe ''
should be treated like null
. I think it is technically correct to try to parse it though. We don't know what the generic type D
will be, but it could be string
. If its not string
people shouldn't really be passing ''
anyways. I think we can keep it like this and try to presubmit it in Google. If we find a lot of people using ''
to mean null
we may want to change it
…nput (#24813) * fix(material/datepicker): add ability to have numeric zero value in input Shows valid formatted value for 'falsy' values (exp 0) Custom DateAdapter (exp TimestampDateAdapter) can have valid numeric 0 value (for timestamp it is 1/1/1970), but datepicker input doesn't show formatted value * fix(material/datepicker): add ability to have numeric zero value in input Add tests (cherry picked from commit 5f4d7e2)
…nput (#24813) * fix(material/datepicker): add ability to have numeric zero value in input Shows valid formatted value for 'falsy' values (exp 0) Custom DateAdapter (exp TimestampDateAdapter) can have valid numeric 0 value (for timestamp it is 1/1/1970), but datepicker input doesn't show formatted value * fix(material/datepicker): add ability to have numeric zero value in input Add tests (cherry picked from commit 5f4d7e2)
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@angular/cdk](https://github.com/angular/components) | dependencies | patch | [`13.3.6` -> `13.3.7`](https://renovatebot.com/diffs/npm/@angular%2fcdk/13.3.6/13.3.7) | | [@angular/material](https://github.com/angular/components) | dependencies | patch | [`13.3.6` -> `13.3.7`](https://renovatebot.com/diffs/npm/@angular%2fmaterial/13.3.6/13.3.7) | --- ### Release Notes <details> <summary>angular/components</summary> ### [`v13.3.7`](https://github.com/angular/components/blob/HEAD/CHANGELOG.md#​1337-chiffon-carambola-2022-05-11) [Compare Source](angular/components@13.3.6...13.3.7) ##### material | Commit | Type | Description | | -- | -- | -- | | [0bede63d33](angular/components@0bede63) | fix | **datepicker:** add ability to have numeric zero value in input ([#​24813](angular/components#24813)) | | [7a122f7f03](angular/components@7a122f7) | fix | **expansion:** inconsistent spacing for anchor buttons ([#​24882](angular/components#24882)) | | [e486ed93e4](angular/components@e486ed9) | fix | **menu:** focus the first item when opening menu on iOS VoiceOver ([#​24733](angular/components#24733)) | #### Special Thanks Dmytro Prokhorov, Kristiyan Kostadinov and Zach Arend <!-- CHANGELOG SPLIT MARKER --> </details> --- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Co-authored-by: cabr2-bot <[email protected]> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1349 Reviewed-by: Epsilon_02 <[email protected]> Co-authored-by: Calciumdibromid Bot <[email protected]> Co-committed-by: Calciumdibromid Bot <[email protected]>
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. |
fix(material/datepicker): add ability to have numeric zero value in input
Shows valid formatted value for 'falsy' values (exp 0)
Custom DateAdapter (exp TimestampDateAdapter) can have valid numeric 0 value (for timestamp it is 1/1/1970), but datepicker input doesn't show formatted value