Fix infinite loop for dateRange pickers #2969
Open
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.
PRs relating to the v4 will be closed and locked.
This is a bug fix to address an infinite loop that is triggered in 2 ways:
td.dates.setValue(date, 0)described in Programmatically setting start date earlier than current selection in date range causes infinite loop #2963This PR solves it by attempting to validate the whole date range when the input is changed (since validating the first value to update doesn't make sense if you are swapping out the entire range). It introduces a new
td.dates.setRangeValues(startDate, endDate)to address programmatically updating the range.Fixes #2963
The
validation.dateRangeIsValidmethod attempts to validate every date in the range, but ends up starting past the target date to end the loop on, so it loops forever.There should be no (intentional) behavior change.
I don't believe this introduces a breaking change, unless maybe they are depending on method signatures staying the same. I strived to preserve existing behavior and keep it backwards compatible.
N/A