Skip to content

Conversation

@balajis-qb
Copy link
Contributor

@balajis-qb balajis-qb commented May 12, 2025

Description

Linked issue: #5520

Problem
As mentioned in the linked issue, the datepicker needs 2 esc key press to close. This is not happening always. If the control is there in any days, then one ESC key itself is closing the date picker. But if it's there in the DatePicker header (For E.g., Previous or Next month navigation button), then the first ESC key will just move the focus back to the DatePicker Input and then second Esc key only will close the DatePicker.

To Reproduce
Steps to reproduce the behavior:

  1. Go to a page with react-datepicker rendered.
  2. Click on the input field to open the calendar and click back and next navigate button for more than one times.
  3. Press Escape.
  4. Observe that the calendar remains open (It just moves the focus to the input).
  5. Press Escape again.
  6. Calendar finally closes.

Changes

  • Added the missing handleClose call to the onPopperKeyDown event handler
    image

Contribution checklist

  • I have followed the contributing guidelines.
  • I have added sufficient test coverage for my changes.
  • I have formatted my code with Prettier and checked for linting issues with ESLint for code readability.

@codecov
Copy link

codecov bot commented May 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.99%. Comparing base (6f0da37) to head (0661e58).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5621   +/-   ##
=======================================
  Coverage   96.98%   96.99%           
=======================================
  Files          30       30           
  Lines        3355     3356    +1     
  Branches     1416     1420    +4     
=======================================
+ Hits         3254     3255    +1     
+ Misses        101       99    -2     
- Partials        0        2    +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martijnrusschen martijnrusschen merged commit fb58b2a into Hacker0x01:main May 12, 2025
6 checks passed
@HugoLiconV
Copy link

Hi @balajis-qb Thank you so much for the fix and your time. I tested your changes, and the behavior continues: I must press Esc twice to close the calendar. Let me share a screen recording where you can see the behavior and the keys I'm pressing.

Screen.Recording.2025-05-19.at.1.13.15.p.m.mov

Could you please let me know if that's the intended behavior?

Again, thank you for your time

@balajis-qb
Copy link
Contributor Author

Hi @HugoLiconV ,

Are you using the latest version of the package? Because previously also I can able to reproduce the issue only when the header arrows are focused (I added the steps to reproduce). I fixed that and now I couldn't able to reproduce the issue.

If this issue is coming for any specific case, please share your example code.

@SaiBalaji202
Copy link

react-datepicker-issue.mp4

Just sharing the screenrecording I tried. I couldn't able to reproduce.

@HugoLiconV
Copy link

Hi again, @balajis-qb. Yes, I updated my local branch and ensured your changes were there. I think the problem is that we're following different steps. Here's how you can reproduce it:

Note

You don't need any specific setup. You can reproduce it using the default example in https://reactdatepicker.com/

  1. Click on the input field to open the calendar (Don't press any key)
  2. The focus will be on the Input Field
  3. Press Escape.
  4. Observe that the calendar remains open, but the focus moves to the Date Picker
  5. Press Escape again.
  6. Calendar finally closes.

Please let me know if you can replicate it with these steps.
Thanks

@HugoLiconV
Copy link

Hi @balajis-qb, just wanted to ask if you were able to reproduce the issue

@balajis-qb
Copy link
Contributor Author

Hi @HugoLiconV , I couldn't reproduce the issue. I attached a screen-recording I tried in the previous comments.

DawoudIO added a commit to ChurchCRM/CRM that referenced this pull request Jul 7, 2025
![snyk-top-banner](https://res.cloudinary.com/snyk/image/upload/r-d/scm-platform/snyk-pull-requests/pr-banner-default.svg)


<h3>Snyk has created this PR to upgrade react-datepicker from 8.3.0 to
8.4.0.</h3>

:information_source: Keep your dependencies up-to-date. This makes it
easier to fix existing vulnerabilities and to more quickly identify and
fix newly disclosed vulnerabilities when they affect your project.

<hr/>


- The recommended version is **1 version** ahead of your current
version.

- The recommended version was released **a month ago**.



<details>
<summary><b>Release notes</b></summary>
<br/>
  <details>
    <summary>Package name: <b>react-datepicker</b></summary>
    <ul>
      <li>
<b>8.4.0</b> - <a
href="https://redirect.github.com/Hacker0x01/react-datepicker/releases/tag/v8.4.0">2025-05-25</a></br><h2>What's
Changed</h2>
<ul>
<li>Fix readOnly prop for a clearButton and inline calendare by <a
class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/SergeyKazarinov/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/SergeyKazarinov">@ SergeyKazarinov</a>
in <a class="issue-link js-issue-link" data-error-text="Failed to load
title" data-id="2991375173" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5564"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5564/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5564">#5564</a></li>
<li>Fix <a class="issue-link js-issue-link" data-error-text="Failed to
load title" data-id="2999650705" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5573"
data-hovercard-type="issue"
data-hovercard-url="/Hacker0x01/react-datepicker/issues/5573/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/issues/5573">#5573</a>
🐛 Fix the Selected Year Picker style when no date is selected by <a
class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/balajis-qb/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/balajis-qb">@ balajis-qb</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="3006849862" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5584"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5584/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5584">#5584</a></li>
<li>Parse date range with dashes by <a class="user-mention notranslate"
data-hovercard-type="user"
data-hovercard-url="/users/alexz-sg/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/alexz-sg">@ alexz-sg</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="3002849585" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5578"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5578/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5578">#5578</a></li>
<li>Include SCSS files in exports by <a class="user-mention notranslate"
data-hovercard-type="user" data-hovercard-url="/users/saltire/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/saltire">@ saltire</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="2984074621" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5560"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5560/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5560">#5560</a></li>
<li>🐛 Add missing datepicker close call onPopperKeyDown event - to
handle ESC keydown event outside the day component by <a
class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/balajis-qb/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/balajis-qb">@ balajis-qb</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="3055666607" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5621"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5621/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5621">#5621</a></li>
<li>🐛 Fix EndDatePicker selection range progress by <a
class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/balajis-qb/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/balajis-qb">@ balajis-qb</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="3054052205" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5619"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5619/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5619">#5619</a></li>
<li>Add Claude Code GitHub Workflow by <a class="user-mention
notranslate" data-hovercard-type="user"
data-hovercard-url="/users/martijnrusschen/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/martijnrusschen">@ martijnrusschen</a>
in <a class="issue-link js-issue-link" data-error-text="Failed to load
title" data-id="3084187602" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5640"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5640/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5640">#5640</a></li>
<li>Move away from <a class="user-mention notranslate"
data-hovercard-type="organization"
data-hovercard-url="/orgs/import/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/import">@ import</a> by <a
class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/martijnrusschen/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/martijnrusschen">@ martijnrusschen</a>
in <a class="issue-link js-issue-link" data-error-text="Failed to load
title" data-id="2858784029" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5426"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5426/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5426">#5426</a></li>
<li>🐛 Apply --keyboard-selected to only if it's not already selected by
<a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/balajis-qb/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/balajis-qb">@ balajis-qb</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="3089230056" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5651"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5651/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5651">#5651</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/alexz-sg/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/alexz-sg">@ alexz-sg</a> made their
first contribution in <a class="issue-link js-issue-link"
data-error-text="Failed to load title" data-id="3002849585"
data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5578"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5578/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5578">#5578</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a class="commit-link"
href="https://redirect.github.com/Hacker0x01/react-datepicker/compare/v8.3.0...v8.4.0"><tt>v8.3.0...v8.4.0</tt></a></p>
      </li>
      <li>
<b>8.3.0</b> - <a
href="https://redirect.github.com/Hacker0x01/react-datepicker/releases/tag/v8.3.0">2025-04-09</a></br><h2>What's
Changed</h2>
<ul>
<li>🐛🎨 Apply the <code>--selected</code> class for the YearPicker when
the <code>selectsMultiple</code> is enabled by <a class="user-mention
notranslate" data-hovercard-type="user"
data-hovercard-url="/users/balajis-qb/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/balajis-qb">@ balajis-qb</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="2959609233" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5524"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5524/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5524">#5524</a></li>
<li>Fix <a class="issue-link js-issue-link" data-error-text="Failed to
load title" data-id="2924009885" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5502"
data-hovercard-type="issue"
data-hovercard-url="/Hacker0x01/react-datepicker/issues/5502/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/issues/5502">#5502</a>:
🐛 Fix '--in-selecting-range' class apply condition for End Date Picker
by <a class="user-mention notranslate" data-hovercard-type="user"
data-hovercard-url="/users/balajis-qb/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/balajis-qb">@ balajis-qb</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="2924034579" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5503"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5503/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5503">#5503</a></li>
<li>🎨🔨 Re-adjust the height of TimePicker on Calendar resize due to
number of days by <a class="user-mention notranslate"
data-hovercard-type="user"
data-hovercard-url="/users/balajis-qb/hovercard"
data-octo-click="hovercard-link-click"
data-octo-dimensions="link_type:self"
href="https://redirect.github.com/balajis-qb">@ balajis-qb</a> in <a
class="issue-link js-issue-link" data-error-text="Failed to load title"
data-id="2975931816" data-permission-text="Title is private"
data-url="Hacker0x01/react-datepicker#5539"
data-hovercard-type="pull_request"
data-hovercard-url="/Hacker0x01/react-datepicker/pull/5539/hovercard"
href="https://redirect.github.com/Hacker0x01/react-datepicker/pull/5539">#5539</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a class="commit-link"
href="https://redirect.github.com/Hacker0x01/react-datepicker/compare/v8.2.1...v8.3.0"><tt>v8.2.1...v8.3.0</tt></a></p>
      </li>
    </ul>
from <a
href="https://redirect.github.com/Hacker0x01/react-datepicker/releases">react-datepicker
GitHub release notes</a>
  </details>
</details>

---

> [!IMPORTANT]
>
> - Check the changes in this PR to ensure they won't cause issues with
your project.
> - This PR was automatically created by Snyk using the credentials of a
real user.

---

**Note:** _You are seeing this because you or someone else with access
to this repository has authorized Snyk to open upgrade PRs._

**For more information:** <img
src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiIzMzc0YWFkMi0wNzJhLTQyNDUtOTgzYi1mZjhmNzAyYWI2NjQiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6IjMzNzRhYWQyLTA3MmEtNDI0NS05ODNiLWZmOGY3MDJhYjY2NCJ9fQ=="
width="0" height="0"/>

> - 🧐 [View latest project
report](https://app.snyk.io/org/dawoudio/project/e27b08aa-e5d2-4b10-8303-630a69d0b669?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)
> - 📜 [Customise PR
templates](https://docs.snyk.io/scan-using-snyk/pull-requests/snyk-fix-pull-or-merge-requests/customize-pr-templates?utm_source=&utm_content=fix-pr-template)
> - 🛠 [Adjust upgrade PR
settings](https://app.snyk.io/org/dawoudio/project/e27b08aa-e5d2-4b10-8303-630a69d0b669/settings/integration?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr)
> - 🔕 [Ignore this dependency or unsubscribe from future upgrade
PRs](https://app.snyk.io/org/dawoudio/project/e27b08aa-e5d2-4b10-8303-630a69d0b669/settings/integration?pkg&#x3D;react-datepicker&amp;utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr#auto-dep-upgrades)

[//]: #
'snyk:metadata:{"customTemplate":{"variablesUsed":[],"fieldsUsed":[]},"dependencies":[{"name":"react-datepicker","from":"8.3.0","to":"8.4.0"}],"env":"prod","hasFixes":false,"isBreakingChange":false,"isMajorUpgrade":false,"issuesToFix":[],"prId":"3374aad2-072a-4245-983b-ff8f702ab664","prPublicId":"3374aad2-072a-4245-983b-ff8f702ab664","packageManager":"npm","priorityScoreList":[],"projectPublicId":"e27b08aa-e5d2-4b10-8303-630a69d0b669","projectUrl":"https://app.snyk.io/org/dawoudio/project/e27b08aa-e5d2-4b10-8303-630a69d0b669?utm_source=github&utm_medium=referral&page=upgrade-pr","prType":"upgrade","templateFieldSources":{"branchName":"default","commitMessage":"default","description":"default","title":"default"},"templateVariants":[],"type":"auto","upgrade":[],"upgradeInfo":{"versionsDiff":1,"publishedDate":"2025-05-25T12:21:10.113Z"},"vulns":[]}'
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.

4 participants