Skip to content

Commit

Permalink
Split widgetWrapper to calendarWrapper and clockWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Nov 9, 2022
1 parent 7828ada commit c563d9b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/DateTimeRangePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export default class DateTimeRangePicker extends PureComponent {

wrapper = createRef();

widgetWrapper = createRef();
calendarWrapper = createRef();

clockWrapper = createRef();

componentDidMount() {
this.handleOutsideActionListeners();
Expand Down Expand Up @@ -73,15 +75,16 @@ export default class DateTimeRangePicker extends PureComponent {
}

onOutsideAction = (event) => {
const { wrapper, widgetWrapper } = this;
const { wrapper, calendarWrapper, clockWrapper } = this;

// Try event.composedPath first to handle clicks inside a Shadow DOM.
const target = 'composedPath' in event ? event.composedPath()[0] : event.target;

if (
wrapper.current &&
!wrapper.current.contains(target) &&
(!widgetWrapper.current || !widgetWrapper.current.contains(target))
(!calendarWrapper.current || !calendarWrapper.current.contains(target)) &&
(!clockWrapper.current || !clockWrapper.current.contains(target))
) {
this.closeWidgets();
}
Expand Down Expand Up @@ -412,7 +415,7 @@ export default class DateTimeRangePicker extends PureComponent {

return portalContainer ? (
createPortal(
<div ref={this.widgetWrapper} className={classNames}>
<div ref={this.calendarWrapper} className={classNames}>
{calendar}
</div>,
portalContainer,
Expand Down Expand Up @@ -470,7 +473,7 @@ export default class DateTimeRangePicker extends PureComponent {

return portalContainer ? (
createPortal(
<div ref={this.widgetWrapper} className={classNames}>
<div ref={this.clockWrapper} className={classNames}>
{clock}
</div>,
portalContainer,
Expand Down

0 comments on commit c563d9b

Please sign in to comment.