[DatePicker] Add a default text value #4358
Closed
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.