Skip to content

fix(calendar-compat): prevent component from crashing if value is undefined#35798

Open
mainframev wants to merge 2 commits intomicrosoft:masterfrom
mainframev:fix/calendar-compat-value
Open

fix(calendar-compat): prevent component from crashing if value is undefined#35798
mainframev wants to merge 2 commits intomicrosoft:masterfrom
mainframev:fix/calendar-compat-value

Conversation

@mainframev
Copy link
Contributor

Updated Calendar to prevent crashes by checking if selectedDate exists before using it, and by defaulting selectedDate and navigatedDay to today if they are undefined

Previous Behavior

explicit undefined crashing component

New Behavior

Added selectedDate guard to the formatter conditional so dateStringFormatter is never called with undefined. Replaced selectedDate! non-null assertion with selectedDate ?? today

Related Issue(s)

@mainframev mainframev requested review from a team and ValentinaKozlova as code owners February 27, 2026 08:48
@mainframev mainframev self-assigned this Feb 27, 2026
@mainframev mainframev added the Component: Calendar Compat Calendar Compat component label Feb 27, 2026
@github-actions
Copy link

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-calendar-compat
Calendar Compat
149.207 kB
39.833 kB
149.23 kB
39.847 kB
23 B
14 B
react-datepicker-compat
DatePicker Compat
225.038 kB
63.595 kB
225.061 kB
63.608 kB
23 B
13 B

🤖 This report was generated against 80e5e0651f604b7e45a5595c5b8d00b4e34f554f

@github-actions
Copy link

Pull request demo site: URL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Calendar Compat Calendar Compat component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Calendar is not accepting undefined

1 participant