fix: resolve calendar drag-and-drop not persisting post date changes #854
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
Problem
When dragging posts on the Edit Flow calendar, the JavaScript crashed with:
The root cause was that
calendar.jsuseddispatch('edit-flow/calendar')but the React bundle that registers this data store wasn't listed as a dependency. The store wasundefinedwhen the jQuery code ran, causing the crash before the AJAX request was made.Solution
Script dependency fix (
calendar.php): Reordered script enqueue so the React bundle loads beforecalendar.js, and addededit-flow-calendar-react-jsas an explicit dependency.Defensive coding (
calendar.js): AddedgetCalendarDispatch()helper that returns no-op functions if the store isn't available, ensuring the AJAX request always proceeds.Regression tests (
CalendarModuleTest.php): Added tests verifying that posts with the same timestamp are correctly retrieved (the original reported symptom).Test plan
composer test:integration -- --filter=CalendarModuleTest(24 tests pass)Fixes #770
🤖 Generated with Claude Code