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

fix: handling document click after manual update #2419

Merged
merged 3 commits into from Mar 6, 2022

Conversation

Sayan751
Copy link

Primarily it fixes #2394

The cause of the issue
When manual input is allowed, the user input was not respected, when a user clicks anywhere in the document body instead of pressing TAB key. This results in 'click'->'blur' event sequence as opposed to only a blur event. This results in setting the date always from the calendar element.

The fix
The fix compares the date from the input with the latest selected date; if it matches then the changes is coming from the calendar control and updates the date time from calendar control, as before. Otherwise the change is coming from the input control, and it simply overwrites the latest selected date. The synchronization step later takes care of the rest, as before.

Additionally, it contains changes to close the calendar popup when ENTER is pressed on the input field. This is similar to the ENTER handling behavior on the time input fields.

Pal,Sayan added 3 commits February 25, 2021 11:25
When manual input is allowed, the user input was not respected, when
a user clicks anywhere in the document body instead of pressing TAB key.
This results in 'click'->'blur' event sequence as opposed to only a
blur event. This results in setting the date always from the calendar
element.

The fix compares the date from the input with the latest selected date;
if it matches then the changes is coming from the calendar control and
updates the date time from calendar control, as before. Otherwise the
change is coming from the input control, and it simply overwrites the
latest selected date. The synchronization step later takes care of
the rest, as before.
This is similar to ENTER handling behvior on the time inputs.
@iluuu1994
Copy link

@chmln I have the same issue. Does this fix need any adjustments?

@chmln chmln merged commit 99c9bbf into flatpickr:master Mar 6, 2022
kodiakhq bot pushed a commit to carbon-design-system/carbon-for-ibm-dotcom that referenced this pull request Mar 9, 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.9` -> `4.6.10`](https://renovatebot.com/diffs/npm/flatpickr/4.6.9/4.6.10) | [![age](https://badges.renovateapi.com/packages/npm/flatpickr/4.6.10/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/flatpickr/4.6.10/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/flatpickr/4.6.10/compatibility-slim/4.6.9)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/flatpickr/4.6.10/confidence-slim/4.6.9)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

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

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

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

##### What's Changed

-   Support Z & GMT custom parsing by [@&#8203;bcfox](https://togithub.com/bcfox) in [flatpickr/flatpickr#2369
-   🌐 \[ar] Translate missing phrases. by [@&#8203;mohamedsabil83](https://togithub.com/mohamedsabil83) in [flatpickr/flatpickr#2370
-   fix: restrict onKeyDown listener to Flatpickr only fixes [#&#8203;1444](https://togithub.com/chmln/flatpickr/issues/1444), [#&#8203;1387](https://togithub.com/chmln/flatpickr/issues/1387) by [@&#8203;ghiscoding](https://togithub.com/ghiscoding) in [flatpickr/flatpickr#2329
-   🌐\[ko] Add missing am/pm translation by [@&#8203;darron1217](https://togithub.com/darron1217) in [flatpickr/flatpickr#2379
-   Add missing horizontal position strings to position option type by [@&#8203;danielpierre](https://togithub.com/danielpierre) in [flatpickr/flatpickr#2400
-   Support reversed ranges for minTime and maxTime by [@&#8203;MiroslavCsonka](https://togithub.com/MiroslavCsonka) in [flatpickr/flatpickr#2482
-   Fix incorrectly migrated package-lock.json by [@&#8203;andersk](https://togithub.com/andersk) in [flatpickr/flatpickr#2467
-   Compile all ES6+ syntax to ES5 by [@&#8203;andersk](https://togithub.com/andersk) in [flatpickr/flatpickr#2469
-   \[fix] apply positionElement to instance.\_positionElement when fp.set by [@&#8203;fifzteen](https://togithub.com/fifzteen) in [flatpickr/flatpickr#2466
-   Fix rangePlugin selection problems by [@&#8203;SquareBeard](https://togithub.com/SquareBeard) in [flatpickr/flatpickr#1795
-   Fix maxTime bound bug by [@&#8203;MiroslavCsonka](https://togithub.com/MiroslavCsonka) in [flatpickr/flatpickr#2483
-   Fix parseDate on relative inputs by [@&#8203;juliapath](https://togithub.com/juliapath) in [flatpickr/flatpickr#2475
-   Add range separator for Swedish locale by [@&#8203;mlonn](https://togithub.com/mlonn) in [flatpickr/flatpickr#2434
-   Update sv.ts by [@&#8203;davemccrea](https://togithub.com/davemccrea) in [flatpickr/flatpickr#2449
-   feat: add norwegian nynorsk by [@&#8203;tw15egan](https://togithub.com/tw15egan) in [flatpickr/flatpickr#2423
-   Update fi.ts by [@&#8203;davemccrea](https://togithub.com/davemccrea) in [flatpickr/flatpickr#2450
-   Eliminate memory leak caused by event listener accumulation by [@&#8203;jefrailey](https://togithub.com/jefrailey) in [flatpickr/flatpickr#2596
-   Adjusts month abbreviation and adds aria-labels for the Greek translation (i10n) by [@&#8203;delight](https://togithub.com/delight) in [flatpickr/flatpickr#2555
-   Keyboard doesn't work inside Shadow Dom by [@&#8203;mwoess](https://togithub.com/mwoess) in [flatpickr/flatpickr#2519
-   Check exsitance of years and month in scrollPlugin by [@&#8203;mojtaba-khallash](https://togithub.com/mojtaba-khallash) in [flatpickr/flatpickr#2571
-   Create ar-dz.ts locales by [@&#8203;anugrahsoft](https://togithub.com/anugrahsoft) in [flatpickr/flatpickr#2556
-   fix: `onClose` callback was returning wrong selected dates if user changed input before close. by [@&#8203;DimitrisRK](https://togithub.com/DimitrisRK) in [flatpickr/flatpickr#2541
-   Remove repeating 'onChange' trigger by [@&#8203;quis0](https://togithub.com/quis0) in [flatpickr/flatpickr#2506
-   Append to container and children no longer classed as calendar elements by [@&#8203;cmubo](https://togithub.com/cmubo) in [flatpickr/flatpickr#2500
-   Updated week day for Sunday in ms.ts by [@&#8203;izwanakhirruddin](https://togithub.com/izwanakhirruddin) in [flatpickr/flatpickr#2496
-   Add range separator to Catalan by [@&#8203;toniavanza](https://togithub.com/toniavanza) in [flatpickr/flatpickr#2495
-   Fix for calendar position on Safari by [@&#8203;octaviofernands](https://togithub.com/octaviofernands) in [flatpickr/flatpickr#2391
-   chore: replace CircleCI status badge with GitHub Actions status by [@&#8203;ghiscoding](https://togithub.com/ghiscoding) in [flatpickr/flatpickr#2384
-   monthSelect plugin: Support "range" mode by [@&#8203;rlue](https://togithub.com/rlue) in [flatpickr/flatpickr#2297
-   fix: GitHub Actions badge fix invalid url typo by [@&#8203;ghiscoding](https://togithub.com/ghiscoding) in [flatpickr/flatpickr#2597
-   add Armenian locale by [@&#8203;vakopian](https://togithub.com/vakopian) in [flatpickr/flatpickr#2604
-   Fixes confirmDate focus accessibility by [@&#8203;gustavoaz7](https://togithub.com/gustavoaz7) in [flatpickr/flatpickr#2633
-   Add 'time\_24hr: true' to Austrian locale by [@&#8203;berndy2001](https://togithub.com/berndy2001) in [flatpickr/flatpickr#2612
-   Prevent text selection on prev/next month buttons by [@&#8203;metonym](https://togithub.com/metonym) in [flatpickr/flatpickr#2603
-   Fix issues with parsing localized date/time by [@&#8203;mshibuya](https://togithub.com/mshibuya) in [flatpickr/flatpickr#2600
-   add kurdish (sorani) language by [@&#8203;swara-mohammed](https://togithub.com/swara-mohammed) in [flatpickr/flatpickr#2620
-   Fix [#&#8203;2541](https://togithub.com/chmln/flatpickr/issues/2541) breaking with altInput enabled by [@&#8203;mshibuya](https://togithub.com/mshibuya) in [flatpickr/flatpickr#2601
-   fix: handling document click after manual update  by [@&#8203;Sayan751](https://togithub.com/Sayan751) in [flatpickr/flatpickr#2419

##### New Contributors

-   [@&#8203;bcfox](https://togithub.com/bcfox) made their first contribution in [flatpickr/flatpickr#2369
-   [@&#8203;mohamedsabil83](https://togithub.com/mohamedsabil83) made their first contribution in [flatpickr/flatpickr#2370
-   [@&#8203;darron1217](https://togithub.com/darron1217) made their first contribution in [flatpickr/flatpickr#2379
-   [@&#8203;danielpierre](https://togithub.com/danielpierre) made their first contribution in [flatpickr/flatpickr#2400
-   [@&#8203;MiroslavCsonka](https://togithub.com/MiroslavCsonka) made their first contribution in [flatpickr/flatpickr#2482
-   [@&#8203;andersk](https://togithub.com/andersk) made their first contribution in [flatpickr/flatpickr#2467
-   [@&#8203;fifzteen](https://togithub.com/fifzteen) made their first contribution in [flatpickr/flatpickr#2466
-   [@&#8203;juliapath](https://togithub.com/juliapath) made their first contribution in [flatpickr/flatpickr#2475
-   [@&#8203;mlonn](https://togithub.com/mlonn) made their first contribution in [flatpickr/flatpickr#2434
-   [@&#8203;davemccrea](https://togithub.com/davemccrea) made their first contribution in [flatpickr/flatpickr#2449
-   [@&#8203;tw15egan](https://togithub.com/tw15egan) made their first contribution in [flatpickr/flatpickr#2423
-   [@&#8203;jefrailey](https://togithub.com/jefrailey) made their first contribution in [flatpickr/flatpickr#2596
-   [@&#8203;delight](https://togithub.com/delight) made their first contribution in [flatpickr/flatpickr#2555
-   [@&#8203;mwoess](https://togithub.com/mwoess) made their first contribution in [flatpickr/flatpickr#2519
-   [@&#8203;mojtaba-khallash](https://togithub.com/mojtaba-khallash) made their first contribution in [flatpickr/flatpickr#2571
-   [@&#8203;anugrahsoft](https://togithub.com/anugrahsoft) made their first contribution in [flatpickr/flatpickr#2556
-   [@&#8203;DimitrisRK](https://togithub.com/DimitrisRK) made their first contribution in [flatpickr/flatpickr#2541
-   [@&#8203;quis0](https://togithub.com/quis0) made their first contribution in [flatpickr/flatpickr#2506
-   [@&#8203;cmubo](https://togithub.com/cmubo) made their first contribution in [flatpickr/flatpickr#2500
-   [@&#8203;izwanakhirruddin](https://togithub.com/izwanakhirruddin) made their first contribution in [flatpickr/flatpickr#2496
-   [@&#8203;toniavanza](https://togithub.com/toniavanza) made their first contribution in [flatpickr/flatpickr#2495
-   [@&#8203;octaviofernands](https://togithub.com/octaviofernands) made their first contribution in [flatpickr/flatpickr#2391
-   [@&#8203;vakopian](https://togithub.com/vakopian) made their first contribution in [flatpickr/flatpickr#2604
-   [@&#8203;gustavoaz7](https://togithub.com/gustavoaz7) made their first contribution in [flatpickr/flatpickr#2633
-   [@&#8203;berndy2001](https://togithub.com/berndy2001) made their first contribution in [flatpickr/flatpickr#2612
-   [@&#8203;metonym](https://togithub.com/metonym) made their first contribution in [flatpickr/flatpickr#2603
-   [@&#8203;mshibuya](https://togithub.com/mshibuya) made their first contribution in [flatpickr/flatpickr#2600
-   [@&#8203;swara-mohammed](https://togithub.com/swara-mohammed) made their first contribution in [flatpickr/flatpickr#2620
-   [@&#8203;Sayan751](https://togithub.com/Sayan751) made their first contribution in [flatpickr/flatpickr#2419

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

</details>

---

### Configuration

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

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

♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 **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).
mshibuya added a commit to mshibuya/flatpickr that referenced this pull request Mar 12, 2022
chmln added a commit that referenced this pull request Mar 12, 2022
Fix #2419 breaking with altInput and altFormat Enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blur event not setting date correctly when allowInput true
3 participants