Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heading, List: Fix onMerge errors #3917

Merged
merged 3 commits into from
Dec 12, 2017
Merged

Heading, List: Fix onMerge errors #3917

merged 3 commits into from
Dec 12, 2017

Conversation

mcsf
Copy link
Contributor

@mcsf mcsf commented Dec 11, 2017

Fixes #3867

Description

  • Hitting Enter in a Heading throws an TypeError (described in Heading: Uncaught TypeError when pressing Enter #3867) due to an onKeyDown event propagating when splitting content, as @ephox-mogran noticed.
  • While fixing and testing the above, I noticed errors thrown when merging lists into paragraphs, though the same issue happened when transforming lists into paragraphs and quotes.

How Has This Been Tested?

  1. Start an empty post.
  2. Add a heading with text.
  3. With the cursor at the end of the heading's text field, paste a paragraph of HTML grabbed from somewhere—see the attached example after this list.
  4. Ensure no errors are logged and that the text is pasted into a new paragraph, retaining the original heading as is.
  5. After the paragraph, add a list with more than one item.
  6. With the cursor at the beginning of the list, hit backspace.
  7. Ensure no errors are logged and that the list is correctly transformed into paragraphs, the first of which merged into the original paragraph.

Attachment 1: Example HTML paragraph

Letterpress printing is a technique of relief printing using a printing press, a process by which many copies are produced by repeated direct impression of an inked, raised surface against sheets or a continuous roll of paper. A worker composes and locks movable type into the "bed" or "chase" of a press, inks it, and presses paper against it to transfer the ink from the type which creates an impression on the paper.

Screenshots (jpeg or gifs if applicable):

Before After
gutenberg-heading-enter-before gutenberg-heading-enter-after
gutenberg-list-merge-before gutenberg-list-merge-after

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows has proper inline documentation.

@mcsf mcsf added the [Feature] Blocks Overall functionality of blocks label Dec 11, 2017
Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good to me 👍 .
I tested the code and I did not found any regression. Regarding the console errors in transforms I was able to reproduce them in master and here they are fixed. For the errors in the heading, I did not manage to reproduce them in master. I think a parallel change may have changed the behavior but according to the discussion, the related change done here makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Heading: Uncaught TypeError when pressing Enter
2 participants