-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 date selection issue with withPortal or appendToBody. Fixes #1535. #1540
Conversation
This appears to be failing tests. |
@ljharb Ok, let me check and get back to you |
@ljharb Updated the PR. |
src/components/SingleDatePicker.jsx
Outdated
if (this.container.contains(e.relatedTarget || e.target)) return; | ||
if ( | ||
this.dayPickerContainer | ||
&& this.dayPickerContainer.contains(e.relatedTarget || e.target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not sure this is the right change - is it possible the relevant tests were mocking this.container but need to be updated to mock this.dayPickerContainer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even I thought of that. The fact is that there are always 2 refs - the outer ref this.container
, and the inner ref this.dayPickerContainer
. The issue was caused because the wrong container ref was being searched in case of elements rendered in portal. So I referred to DateRangePicker.jsx
, where I saw that this.dayPickerContainer
was the one being used in focusOut
handler. And thus the change.
So should we update the tests, or is the change wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your change might be perfect :-) but maybe you could add tests that would help ensure it's not broken in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the ref being used inside the test, and reverted the previous check. @ljharb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable to me. cc: @monokrome it seems like your fix was incomplete.
@danedavid Does the DateRangePicker still currently work?
@majapw Not sure that my fix didn't work. Seems unrelated to me - which use case wasn't working in 19.0.2? |
@monokrome Sorry I wasn't clear! This issue seemed very similar to #1522 (clicking anywhere closes the SingleDatePicker) as it was related to the SDP autoclosing and the |
Fixes #1535 .