Skip to content

Commit 282fbb8

Browse files
committed
fix: 5428 ContainerRef Propagation
1 parent cd1789c commit 282fbb8

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/calendar.tsx

Lines changed: 1 addition & 0 deletions
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}

src/day.tsx

Lines changed: 2 additions & 2 deletions
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;
@@ -532,7 +532,7 @@ export default class Day extends Component<DayProps> {
532532
// the activeElement is in the container, and it is another instance of Day
533533
private isDayActiveElement() {
534534
return (
535-
this.props.containerRef?.current?.contains(document.activeElement) &&
535+
this.props.containerRef.current?.contains(document.activeElement) &&
536536
document.activeElement?.classList.contains("react-datepicker__day")
537537
);
538538
}

src/week_number.tsx

Lines changed: 1 addition & 1 deletion
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)