shownDate changes do not change Calendar #552 #625
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.
Problem Statement
We need a way to manually change the shown date to a specific month because it is not always relevant to automatically navigate to the selected start date itself. Currently, this package offers an attribute named shownDate which does not respond desirably.
Faced Problem Scenario
This problem was faced by me while I was implementing a date range picker with this package. The purpose of that picker is to let users pick vacation ranges from the calendar. However, I had to check existing leaves and vacations while changing each month which updates a state by calling an API. That API update is re-rendering the selected date and the navigation is coming back to that selected date.
Solution of this Pull Request
In this PR, I have added another attribute named setShownDate which will return a callback function to navigate to a specific month. The callback function will take one date parameter. It will simply move the view to that specific date.
How to use
After calling the function from state, the calendar will navigate to the specific date.