Skip to content

Calendar: turn the post overlay into a quick edit modal - #1072

Open
faisalahammad wants to merge 1 commit into
Automattic:developfrom
faisalahammad:feature/829-calendar-quick-edit-modal
Open

faisalahammad wants to merge 1 commit into
Automattic:developfrom
faisalahammad:feature/829-calendar-quick-edit-modal

Conversation

@faisalahammad

Copy link
Copy Markdown

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 Modal from @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_edit AJAX action returns it when a post is opened. It runs the same get_post_information_fields(), ef_calendar_item_information_fields, ef_calendar_item_actions and ef_calendar_item_additional_html code as before. It checks the ef-calendar-modify nonce 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 with ef_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()):

  • Saving a taxonomy now needs the taxonomy's assign_terms capability.
  • Taxonomy saves no longer fail when the Editorial Metadata module is off.
  • Comma separated tags (Alpha, Beta) save again.
  • A taxonomy name that contains tax_ keeps its full name. Only the prefix is stripped now.
  • A save the server rejects shows "Error saving metadata." instead of looking saved.

Store bridge. build/calendar-react.js bundles its own copy of @wordpress/data, so wp.data.dispatch( 'edit-flow/calendar' ) in calendar.js returned 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 sets window.EF_CALENDAR_STORE to the store actions, and calendar.js uses 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):

  • Output from the item hooks above now shows only when a post is opened, and inline <script> tags in it will not run.
  • Code that targets .item-overlay or .item-inner, or binds on #ef-calendar-view for the details, will not reach them anymore.

Known limits:

  • A non-category taxonomy that is emptied is hidden the next time the post is opened, because empty fields are hidden. Tags already worked like this.
  • A double click on a post opens the modal and the second click closes it, because it lands on the backdrop.

Tests: new CalendarQuickEditAjaxTest (7 tests), 5 new tests in CalendarMetadataAjaxTest, 2 in CalendarModuleTest, a Vitest test for the modal, and 2 Playwright tests in calendar-body.spec.js. composer test:integration and composer test:integration-ms pass (298 tests each), npm run test-js passes (23 tests), and composer cs and npm run lint-js are clean. The E2E tests will run in CI.

Steps to Test

  1. Check out the PR and run npm run build.
  2. Turn on the Calendar module. Create a few categories, including a child, and a draft dated this week with two categories, two tags and some editorial metadata.
  3. Go to Dashboard > Calendar and click the draft. A modal opens with the post title, shows a spinner, then the details and the Edit, Trash, Preview and Follow links. No overlay opens in the day cell.
  4. In the Network tab, check that opening the post sends one admin-ajax.php request with action=ef_calendar_get_quick_edit. The page source has no item-information table.
  5. Close the modal with Esc, the X button and a click outside. Tab to a post and press Enter, then Space. The modal opens each time, and focus goes back to the post when it closes.
  6. Click Categories, check another category and a child, and click Save. The value lists all checked categories, and the post editor shows the same.
  7. Uncheck every category and save. The value shows "Uncategorized".
  8. Set Tags to two existing tags separated by a comma and save. Both are saved.
  9. Edit an editorial metadata field, then click Follow. Both work without a page reload.
  10. Turn off the Editorial Metadata module and change a category in the modal. It saves.
  11. Log in as a contributor and open another user's draft. The details are read only, with no Edit or Trash links.
  12. Drag a post to another day. It moves, the spinner and "saved" snackbar show, and the modal does not open.
  13. Double click an empty day to quick create a post. The create form works, and clicking the new post opens it in the modal.

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
@faisalahammad
faisalahammad requested a review from a team as a code owner October 11, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calendar: Evolve post overlay into a Quick Edit modal for enhanced inline editing

1 participant