Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: error thrown and calendar UI broken by invalid input value when allowInput is true and allowInvalidPreload is true #2650

Merged
merged 1 commit into from Mar 12, 2022

Conversation

barszczmm
Copy link
Contributor

Fixes #2649

When allowInput is true and allowInvalidPreload is true and user enters some invalid value into input, Flatpickr throws an error and calendar UI is broken, because of that error. This happens because there is invalid value in self.selectedDates (set by setSelectedDate() function), but code that is executed further in setDate() function assumes that all values in self.selectedDates are always valid Date objects.
This fix adds two simple checks to make sure we are dealing with Date objects before using Date methods.

The error can be reproduced here: https://jsfiddle.net/yd07z3vo/1/

When allowInput is true and allowInvalidPreload is true and user enters
some invalid value into input, Flatpickr throws an error and calendar UI
is broken, because of that error. This happens because there is invalid
value in self.selectedDates (set by setSelectedDate() function), but
code that is executed further in setDate() function assumes that all
values in self.selectedDates are always valid Date objects. This fix
adds two simple checks to make sure we are dealing wth Date objects
before using Date methods.

The error can be reproduced here: https://jsfiddle.net/yd07z3vo/1/
@chmln chmln merged commit cd06580 into flatpickr:master Mar 12, 2022
kodiakhq bot pushed a commit to carbon-design-system/carbon-for-ibm-dotcom that referenced this pull request Mar 21, 2022
[![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [flatpickr](https://flatpickr.js.org) ([source](https://togithub.com/chmln/flatpickr)) | [`4.6.10` -> `4.6.11`](https://renovatebot.com/diffs/npm/flatpickr/4.6.10/4.6.11) | [![age](https://badges.renovateapi.com/packages/npm/flatpickr/4.6.11/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/flatpickr/4.6.11/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/flatpickr/4.6.11/compatibility-slim/4.6.10)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/flatpickr/4.6.11/confidence-slim/4.6.10)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>chmln/flatpickr</summary>

### [`v4.6.11`](https://togithub.com/chmln/flatpickr/releases/v4.6.11)

[Compare Source](https://togithub.com/chmln/flatpickr/compare/v4.6.10...v4.6.11)

There was a bug with time selection since so much stuff got merged in.
New tests have been added to prevent this from happening again.

#### What's Changed

-   Fix [#&#8203;2419](https://togithub.com/chmln/flatpickr/issues/2419) breaking with altInput and altFormat Enabled by [@&#8203;mshibuya](https://togithub.com/mshibuya) in [flatpickr/flatpickr#2662
-   Bug fix: error thrown and calendar UI broken by invalid input value when allowInput is true and allowInvalidPreload is true by [@&#8203;barszczmm](https://togithub.com/barszczmm) in [flatpickr/flatpickr#2650

#### New Contributors

-   [@&#8203;barszczmm](https://togithub.com/barszczmm) made their first contribution in [flatpickr/flatpickr#2650

**Full Changelog**: flatpickr/flatpickr@v4.6.10...v4.6.11

</details>

---

### Configuration

📅 **Schedule**: "every weekend" (UTC).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Never, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/carbon-design-system/carbon-for-ibm-dotcom).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants