Skip to content

Commit 524bc31

Browse files
Merge pull request #5456 from yuki0410-dev/bugfix/5428
fix: 5428 ContainerRef Propagation
2 parents ec0724b + 5ca3e8c commit 524bc31

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

src/calendar.tsx

+20-18
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ export default class Calendar extends Component<CalendarProps, CalendarState> {
991991
<Month
992992
{...Calendar.defaultProps}
993993
{...this.props}
994+
containerRef={this.containerRef}
994995
ariaLabelPrefix={this.props.monthAriaLabelPrefix}
995996
day={monthDate}
996997
onDayClick={this.handleDayClick}
@@ -1123,26 +1124,27 @@ export default class Calendar extends Component<CalendarProps, CalendarState> {
11231124
<ClickOutsideWrapper
11241125
onClickOutside={this.handleClickOutside}
11251126
style={{ display: "contents" }}
1126-
containerRef={this.containerRef}
11271127
ignoreClass={this.props.outsideClickIgnoreClass}
11281128
>
1129-
<Container
1130-
className={clsx("react-datepicker", this.props.className, {
1131-
"react-datepicker--time-only": this.props.showTimeSelectOnly,
1132-
})}
1133-
showTime={this.props.showTimeSelect || this.props.showTimeInput}
1134-
showTimeSelectOnly={this.props.showTimeSelectOnly}
1135-
>
1136-
{this.renderAriaLiveRegion()}
1137-
{this.renderPreviousButton()}
1138-
{this.renderNextButton()}
1139-
{this.renderMonths()}
1140-
{this.renderYears()}
1141-
{this.renderTodayButton()}
1142-
{this.renderTimeSection()}
1143-
{this.renderInputTimeSection()}
1144-
{this.renderChildren()}
1145-
</Container>
1129+
<div style={{ display: "contents" }} ref={this.containerRef}>
1130+
<Container
1131+
className={clsx("react-datepicker", this.props.className, {
1132+
"react-datepicker--time-only": this.props.showTimeSelectOnly,
1133+
})}
1134+
showTime={this.props.showTimeSelect || this.props.showTimeInput}
1135+
showTimeSelectOnly={this.props.showTimeSelectOnly}
1136+
>
1137+
{this.renderAriaLiveRegion()}
1138+
{this.renderPreviousButton()}
1139+
{this.renderNextButton()}
1140+
{this.renderMonths()}
1141+
{this.renderYears()}
1142+
{this.renderTodayButton()}
1143+
{this.renderTimeSection()}
1144+
{this.renderInputTimeSection()}
1145+
{this.renderChildren()}
1146+
</Container>
1147+
</div>
11461148
</ClickOutsideWrapper>
11471149
);
11481150
}

src/click_outside_wrapper.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface ClickOutsideWrapperProps {
66
onClickOutside: ClickOutsideHandler;
77
className?: string;
88
children: React.ReactNode;
9-
containerRef?: React.MutableRefObject<HTMLDivElement | null>;
9+
containerRef?: React.RefObject<HTMLDivElement | null>;
1010
style?: React.CSSProperties;
1111
ignoreClass?: string;
1212
}

src/day.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ interface DayProps
6262
startDate?: Date | null;
6363
endDate?: Date | null;
6464
renderDayContents?: (day: number, date: Date) => React.ReactNode;
65-
containerRef?: React.RefObject<HTMLDivElement>;
65+
containerRef?: React.RefObject<HTMLDivElement | null>;
6666
calendarStartDay?: DateNumberType;
6767
locale?: Locale;
6868
monthShowsDuplicateDaysEnd?: boolean;

src/week_number.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface WeekNumberProps {
1616
inline?: boolean;
1717
shouldFocusDayInline?: boolean;
1818
handleOnKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
19-
containerRef?: React.RefObject<HTMLDivElement>;
19+
containerRef?: React.RefObject<HTMLDivElement | null>;
2020
isInputFocused?: boolean;
2121
isWeekDisabled?: boolean;
2222
}

0 commit comments

Comments
 (0)