Repository navigation
Calendar: turn the post overlay into a quick edit modal - #1072
Open
faisalahammad wants to merge 1 commit into
Open
faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
Clicking a post on the calendar opened a small overlay inside the day cell. It was cramped to read and edit in, and the details table of every post was rendered into the page on load, even though most are never opened. Clicking a post, or pressing Enter or Space on a focused one, now opens a Modal from @wordpress/components. Its content comes from a new ef_calendar_get_quick_edit AJAX action, which runs the same get_post_information_fields() and item hooks as before. The action checks the nonce and the post type, and refuses trashed and other internal posts, and private posts the user cannot read. The overlay markup and CSS are removed. Hierarchical taxonomies such as categories are edited with a wp_terms_checklist() tree, so several terms can be saved at once. Saving a taxonomy now needs its assign_terms capability, works when the Editorial Metadata module is off, and accepts comma separated tag names again. A taxonomy name that contains "tax_" is no longer cut short, and a save the server rejects now shows an error instead of looking saved. The calendar React bundle ships its own copy of @wordpress/data, so calendar.js could not reach the edit-flow/calendar store through wp.data and silently fell back to no-ops. The bundle now exposes the store actions on window.EF_CALENDAR_STORE. This also brings back the spinner and snackbar after dragging a post. The Follow link handler is delegated from the document, so it works inside the modal. Fixes Automattic#829
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.
Description
Fixes #829.
Clicking a post on the calendar now opens a quick edit modal instead of the small overlay inside the day cell. The modal is the
Modalfrom@wordpress/components, so it handles focus, Esc and the backdrop click. Posts can also be focused with Tab and opened with Enter or Space. This covers phases 1 to 3 of the issue. Phase 4 (more fields) is left for a follow up.Details load on demand. The calendar no longer prints the details table of every post into the page. A new
ef_calendar_get_quick_editAJAX action returns it when a post is opened. It runs the sameget_post_information_fields(),ef_calendar_item_information_fields,ef_calendar_item_actionsandef_calendar_item_additional_htmlcode as before. It checks theef-calendar-modifynonce and that the post type is on the calendar, and refuses trashed and other internal posts, and private posts the user cannot read. Like the other calendar actions, it is only registered for users withef_view_calendar.Hierarchical taxonomies. Categories and other hierarchical taxonomies are edited with a
wp_terms_checklist()tree, and all checked terms are saved. Unchecking every category falls back to the default category, the same as core, and the field shows it.Fixes on the same save path (
handle_ajax_update_metadata()):assign_termscapability.Alpha, Beta) save again.tax_keeps its full name. Only the prefix is stripped now.Store bridge.
build/calendar-react.jsbundles its own copy of@wordpress/data, sowp.data.dispatch( 'edit-flow/calendar' )incalendar.jsreturned nothing and the code fell back to no-ops. This is why the spinner and the "saved" snackbar never showed after dragging a post. The bundle now setswindow.EF_CALENDAR_STOREto the store actions, andcalendar.jsuses it.The Follow link click handler is now delegated from
document, so it also works in the modal.For third-party code (might be worth a changelog line):
<script>tags in it will not run..item-overlayor.item-inner, or binds on#ef-calendar-viewfor the details, will not reach them anymore.Known limits:
Tests: new
CalendarQuickEditAjaxTest(7 tests), 5 new tests inCalendarMetadataAjaxTest, 2 inCalendarModuleTest, a Vitest test for the modal, and 2 Playwright tests incalendar-body.spec.js.composer test:integrationandcomposer test:integration-mspass (298 tests each),npm run test-jspasses (23 tests), andcomposer csandnpm run lint-jsare clean. The E2E tests will run in CI.Steps to Test
npm run build.admin-ajax.phprequest withaction=ef_calendar_get_quick_edit. The page source has noitem-informationtable.