Skip to content

feat(datetime): add default picker value input #12698

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

Merged
merged 4 commits into from
Sep 29, 2017
Merged

feat(datetime): add default picker value input #12698

merged 4 commits into from
Sep 29, 2017

Conversation

jacek-jaskolski
Copy link

@jacek-jaskolski jacek-jaskolski commented Aug 18, 2017

Short description of what this resolves:

When datetime input has max value greater than current date its by default selected when datetime picker is opened.

Changes proposed in this pull request:

Added pickerDefault input which is selected if datetime has no value.

Ionic Version: 1.x / 2.x / 3.x
3.x

@AmitMY
Copy link
Contributor

AmitMY commented Aug 18, 2017

Looks good in first glance. I actually need it too.
Can you please add a test for the default value?

@jacek-jaskolski
Copy link
Author

I've added the test. Sorry for multiple commits.

@dkarpik
Copy link

dkarpik commented Sep 18, 2017

Any plans for merging this fix?

@zoinkydoink
Copy link

I also would like to know when this is being planned for release, having to set the controls value so I can have it as a default when it is used by the user is not very user friendly. Right now I am using the ngModel trick but that is not a good work around as I want my field to be empty but default to todays date when the user is ready to pick

@shyamal890
Copy link

+1

@mlynch
Copy link
Contributor

mlynch commented Sep 29, 2017

Thanks for the PR, this has been superseded by the fix in 559f4d3. By default we'll set the value to the current time, or the max value supplied.

Note, to set the default value, you really should just use ngModel and set the value on model. That way it's actually reflected in your code.

@mlynch mlynch closed this Sep 29, 2017
@jacek-jaskolski
Copy link
Author

@mlynch So can we now use max value and default selected date in picker would be current time?
As for you comment. I don't want to update the model because field can be optional. The idea is to make the field easy to use by the users. I want the picker to have a default time closest to the context they in but still user can not provide the date and ngModel should be empty.

@AmitMY
Copy link
Contributor

AmitMY commented Sep 29, 2017

@jacek-jaskolski Has a great use case here. The field has no value until opening, then has a default value given.

@mlynch
Copy link
Contributor

mlynch commented Sep 29, 2017

Follow the issue for updates

@mlynch mlynch reopened this Sep 29, 2017
@mlynch
Copy link
Contributor

mlynch commented Sep 29, 2017

k will be merging this w/ my changes and will have a PR up today

@jacek-jaskolski
Copy link
Author

jacek-jaskolski commented Sep 29, 2017

Thanks @mlynch

@mlynch mlynch merged commit 54cdf00 into ionic-team:master Sep 29, 2017
@mlynch
Copy link
Contributor

mlynch commented Sep 29, 2017

Cool this has been merged with a few updates. Use the initialValue attribute to set the initial value. The actual value of the control won't change unless you hit "done," and the control will automatically use the current time as the initial value if nothing was set, or the max value if the current time is after the max value.

How's that?

@jacek-jaskolski
Copy link
Author

@mlynch This fixses our use case. Thank for the update!

@epiphanatic
Copy link

Is there an equivalent for this in V4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants