Allow to select date or range dates programatically with value attribute #103
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.
Hey there, thanks for the project!
We're integrating this element to have an accessible datepicker. However, we need to be able to have a date selected from the beginning.
The main use case is an edit form, where there's already a date previously selected and we want to allow to select another one. The selected date must be clearly marked, the
start-date
attribute isn't enough.Another scenario is to support a change coming from the server, for example, making column filters in a table, filtering by date. In our case we use morphing for most of the inputs and it was easy to prevent the algorithm from touching the element so that it doesn't lose state. But still, ideally it should be resistant to changing the value attribute so that integration can be simpler.
I also thought about converting the private method
updateValue
to public, but I think that being able to define it from the HTML or JavaScript indistinctly is more consistent.There's the possibility of using the public method
parseDate
, but it doesn't support ranges. If it's useful for that method to accept them too, I could do it in another PR.Now you can initialize the element in the following 2 ways, with the selected date or with the selected date range:
It can also be seen in action on the demo page.