fix: resolve calendar drag-and-drop not persisting post date changes#854
Merged
fix: resolve calendar drag-and-drop not persisting post date changes#854
Conversation
The calendar drag-and-drop was silently failing because the JavaScript
crashed before making the AJAX request. The error was:
"Cannot read properties of null (reading 'setCalendarIsLoading')"
Root cause: calendar.js used dispatch('edit-flow/calendar') but the
React bundle that registers this data store wasn't loaded as a
dependency, so the store was undefined when the jQuery code ran.
Changes:
- Reorder script enqueue so React bundle loads before calendar.js
- Add edit-flow-calendar-react-js as dependency of calendar.js
- Add getCalendarDispatch() helper with graceful fallback to no-op
functions, ensuring AJAX requests proceed even if store unavailable
- Add regression tests for posts with same timestamp being retrieved
Fixes #770
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
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