Skip to content

Conversation

@mikepayready
Copy link

PRs relating to the v4 will be closed and locked.

  • Please check if the PR fulfills these requirements
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...). If this is a fix, please tag a bug.

This is a bug fix to address an infinite loop that is triggered in 2 ways:

  1. Programmatically invoking td.dates.setValue(date, 0) described in Programmatically setting start date earlier than current selection in date range causes infinite loop #2963
  2. Setting the input field manually to a range before the currently selected range

This 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

  • What is the current behavior? (You can also link to an open issue here)

The validation.dateRangeIsValid method 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.

  • What is the new behavior (if this is a feature change)?

There should be no (intentional) behavior change.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

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.

  • Other information:

N/A

…echnically hanging) infinite loop tests, and a fix for the inifinite loop
…y the infinite loop, but also add a sanity check so it is impossible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

Programmatically setting start date earlier than current selection in date range causes infinite loop

1 participant