-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Describe the bug
When making a change to the post content in the Code Editor and retaining focus within the Code Editor's textarea, switching back to Visual Editor reveals that the changes were not applied if the change in editor modes is applied using the keyboard shortcut.
To Reproduce
- Navigate to Posts > Add New
- (Prerequisite) Switch to Code Editor if not already
- Enter text in the Code Editor textarea
- Without leaving the field, press the keyboard combination to switch editor modes (⇧⌥⌘M)
- Note that your changes made in Step 3 are not shown.
Expected behavior
Changes made in Step 3 are shown in Visual Editor.
Additional context
This is due to the PostTextEditor component's "delayed sync" behavior, where we do not parse on individual keypresses, only when the user "finishes editing". The current metric for determining that a user has finished their edits is the blur
event. But within this workflow, the blur
event is not triggered (or at least not handled by PostTextEditor, perhaps due to the fact that it will have unmounted by the time it's called).
A possible fix may be to consider whether there are unsaved changes in the PostTextEditor's componentWillUnmount
and invoking the onPersist
prop.