Skip to content

Commit df8a307

Browse files
committed
Fixed issue
1 parent 4e9fb8c commit df8a307

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/DatepickerContext.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ export function useDatepickerCtx(
9999
}
100100
}
101101

102-
document.addEventListener("mousedown", mouseDownListener);
102+
if (isVisible) {
103+
setMonthYear({ month: date.getMonth(), year: date.getFullYear() });
104+
document.addEventListener("mousedown", mouseDownListener);
105+
}
103106

104107
return () => {
105108
document.removeEventListener("mousedown", mouseDownListener);

0 commit comments

Comments
 (0)