-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: prevent Modal from closing when dismissing DateRangePicker via outside click #9505
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
base: main
Are you sure you want to change the base?
Conversation
snowystinger
left a comment
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.
Thanks for the PR, can you provide a summary of the changes you made and how it solves the problem. I'm having a little trouble understanding how this will always have something to close.
Are we able to write a unit test for this? That could help as well.
| </DatePicker> | ||
| ); | ||
|
|
||
| export const DateRangePickerExample: DateRangePickerStory = (args) => ( |
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.
?
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.
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.
Ah, usually I split them into two functions then, one that's the story and the other is the shareable implementation
| }; | ||
|
|
||
| let onInteractOutsideStart = (e: PointerEvent) => { | ||
| const topMostOverlay = (lastVisibleOverlay.current = visibleOverlays[visibleOverlays.length - 1]); |
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.
| const topMostOverlay = (lastVisibleOverlay.current = visibleOverlays[visibleOverlays.length - 1]); | |
| const topMostOverlay = visibleOverlays[visibleOverlays.length - 1] | |
| lastVisibleOverlay.current = topMostOverlay; |
Makes it easier to read that there are two assignments
|
@snowystinger Do you remember issue #7887? I think it has the same root cause as this one. The problem is that A simple fix would be to only call |
snowystinger
left a comment
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.
@snowystinger Do you remember issue #7887? I think it has the same root cause as this one.
Great call out, I'd forgotten about that one. Thanks.
Also, thanks for writing a test for it and including some more info in the comment. I think the fix makes sense.
Closes #9469
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: