Repository navigation
fix(ios): avoid crash when changing timeZone with minimumDate or maximumDate set - #1079
Open
mokshupadhyay wants to merge 1 commit into
Open
mokshupadhyay wants to merge 1 commit into
mokshupadhyay wants to merge 1 commit into
Conversation
…mumDate set UIDatePicker keeps a loaded calendar's visible month across a time zone change. When minimumDate/maximumDate sits near a month boundary, that month can fall outside the range in the new zone and UIKit throws an NSInternalInconsistencyException. Clear the range while the zone changes and restore it afterwards. The override lives on RNDateTimePicker, so it covers both the Fabric and the old-architecture view. Refs react-native-datetimepicker#1028
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refs #1028
On iOS, changing the time zone of a picker that is already showing its calendar crashes the app when
minimumDateormaximumDateis near a month boundary in the new zone.UIDatePickerkeeps the calendar's visible month across the time zone change, that month can then fall outside the allowed range, and UIKit throws:RNDateTimePickernow overridessetTimeZone:: it clearsminimumDate/maximumDate, sets the zone, and puts them back, so the limits are applied again in the new zone. The Fabric view and the old-architecture manager both useRNDateTimePicker, so both get it.I believe this is the crash in #1028 (the message there, "Unable to set a visible month that is before the minimum or after the maximum date", is a sibling check in the same
UICalendarViewmethod), but I could only reproduce it when the time zone changes after the calendar is shown, not on the first render, and I couldn't test the "device date is the 1st" part without changing the system clock. So this saysRefsrather thanFixes; @-mentioning the reporter on the issue to check their setup.Test Plan
iOS 18.6 simulator, example app (RN 0.83, new architecture), device time zone set with
SIMCTL_CHILD_TZ.What's required for testing (prerequisites)?
A
mode="datetime"picker withdisplay="inline",valueandminimumDate=2026-11-30T23:30:00Z, launched with the device inEurope/London, andtimeZoneName="Europe/Paris"set about a second after mount (e.g. from state).What are the steps to reproduce (after prerequisites)?
timeZoneNamechanges,maincrashes with the exception above.The same crash on
main, and no crash with the change, for: device Paris / picker London withmaximumDate, device Los Angeles / picker Tokyo withminimumDate, andtimeZoneOffsetInMinutes={60}set after mount. Setting the zone on the first render, the compact display, and changingminimumDateor the value after mount did not crash before either.yarn testandyarn lintpass. The old architecture is covered by the same class but I could not run it on RN 0.83.Compatibility
Checklist
README.md(no API change)example/App.js)An AI coding assistant (Claude Code) helped me find and fix this; I reviewed the change and the results.