[DatePicker] Add a default text value#4358
Closed
nathantalewis wants to merge 1 commit intomui:masterfrom
nathantalewis:date-picker-default-text-value
Closed
[DatePicker] Add a default text value#4358nathantalewis wants to merge 1 commit intomui:masterfrom nathantalewis:date-picker-default-text-value
nathantalewis wants to merge 1 commit intomui:masterfrom
nathantalewis:date-picker-default-text-value
Conversation
Member
|
|
Contributor
Author
|
@mbrookes, confirmed that For anyone looking at this in the future, the following works out of the box with v0.15.0 to achieve the same result as the screenshot in the description: <DatePicker
disabled={true}
floatingLabelFixed={true}
floatingLabelText="Checkout Date"
hintText="Today"
/>Closing this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Default Text Field Value is like the Default Date, except that it can be any string rather than just a date object. It has lower priority than the Default Date, so when both are specified the Default Date will be shown.
The use case that I came across was a need to have both the floatingTextField and a non-date initial value for the TextField as seen in the following screenshot next to a similarly modified TimePicker:

In this screenshot, "Today" is the text passed as the defaultTextFieldValue. It could also have been something like "Pick a date" or "None". The styling in the screenshot for the date component is just because it is set to disabled and unrelated to this PR.
The implementation approach for this PR is to just pass this field as the value of the TextField when nothing else is specified.
I can think of two alternate approaches that could achieve the same thing:
If the current approach sounds better than the two alternative approaches, I'll go ahead and write the related tests and update the docs with an example.