Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#53813 closed defect (bug) (fixed)

Do not provide initial_edits for properties that are not supported by the current post type.

Reported by: youknowriad's profile youknowriad Owned by: audrasjb's profile audrasjb
Milestone: 5.9 Priority: normal
Severity: normal Version: 5.8
Component: Editor Keywords: good-first-bug has-patch commit
Focuses: Cc:

Description

I noticed that edit-form-blocks.php (block editor initialization) always provides "title", "content" and "excerpt" initial edits in the initializeEditor call even though these properties might not be supported by the current post type being edited.

This creates a subtle bug in the post editor where as soon as you open a "new post", the editor considers the content "dirty", meaning changes are applied and you can't "leave" the editor without having the "unsaved changes" notice.

I think we should consider updating the $initial_edits variable declaration to only add the properties that are supported by the current CPT.

Attachments (3)

53813.diff (1.1 KB) - added by h71 3 years ago.
53813.2.diff (1.1 KB) - added by h71 3 years ago.
Empty line removed.
a36db167e65d579d6d25f42a79a09567.mp4 (2.4 MB) - added by audrasjb 3 years ago.
Reproducing the issue by removing "excerpt" support in a custom post type

Change History (22)

This ticket was mentioned in Slack in #core by amustaque97. View the logs.


3 years ago

This ticket was mentioned in PR #1743 on WordPress/wordpress-develop by hectorfarahani.


3 years ago
#2

  • Keywords has-patch added

@h71
3 years ago

@h71
3 years ago

Empty line removed.

#3 @h71
3 years ago

My first patch! I had to wait for Github checks. The new diff is attached after passing all checks.

This ticket was mentioned in Slack in #core-editor by h71. View the logs.


3 years ago

#5 @audrasjb
3 years ago

  • Owner set to audrasjb
  • Status changed from new to reviewing

Self-assigning for review.

@audrasjb
3 years ago

Reproducing the issue by removing "excerpt" support in a custom post type

#6 @audrasjb
3 years ago

I can confirm the proposed patch fixes the issue.

Marking for commit.

#7 @audrasjb
3 years ago

  • Keywords commit added

#9 @audrasjb
3 years ago

Tests are passing well.

#10 @audrasjb
3 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 52230:

Editor: Do not provide initial_edits for properties that are not supported by the current post type.

Previously, the block editor initialization always provided "title", "content" and "excerpt" initial edits in the initializeEditor call even though these properties might not be supported by the current post type being edited. This leads to a bug in the post editor where as soon as one would open a "new post", the editor considers the content "dirty", meaning changes are applied and it is not possible to leave the editor without encountering an "unsaved changes" notice.

This change updates the $initial_edits variable declaration to only provide the properties that are supported by the current post type.

Props youknowriad, h71.
Fixes #53813.

audrasjb commented on PR #1927:


3 years ago
#11

Fixed in 52230

audrasjb commented on PR #1743:


3 years ago
#12

Fixed in 52230

#13 @talldanwp
3 years ago

Just want to surface my comment on the PR here - https://github.com/WordPress/wordpress-develop/pull/1743#discussion_r754031590

Looks like this fix caused a bug.

I've created a PR to fix the problem - https://github.com/WordPress/wordpress-develop/pull/1929

Last edited 3 years ago by talldanwp (previous) (diff)

This ticket was mentioned in PR #1929 on WordPress/wordpress-develop by talldan.


3 years ago
#14

Trac ticket: https://core.trac.wordpress.org/ticket/53813

This PR fixes an issue with the already submitted patch for that trac ticket.

See https://github.com/WordPress/wordpress-develop/pull/1743#discussion_r754031590 for details.

audrasjb commented on PR #1929:


3 years ago
#15

Thanks for the fix @talldan, I'll commit this in few mins

#16 @SergeyBiryukov
3 years ago

In 52231:

Editor: Check the correct post type support property for initial_edits.

The property to check should be editor instead of content, as posts don't have a content support property.

This addresses an e2e test failure in Gutenberg.

Follow-up to [52230].

Props talldanwp.
See #53813.

audrasjb commented on PR #1929:


3 years ago
#17

Committed by @SergeyBiryukov in the meantime 😉

SergeyBiryukov commented on PR #1929:


3 years ago
#18

Sorry, didn't know you were around too 😅

audrasjb commented on PR #1929:


3 years ago
#19

No worries, and thank you for jumping into this :)

Note: See TracTickets for help on using tickets.