Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Fix rich text utils backspace not clearing the block type at the start. #748

Closed
wants to merge 3 commits into from
Closed

Fix rich text utils backspace not clearing the block type at the start. #748

wants to merge 3 commits into from

Conversation

jvaill
Copy link
Contributor

@jvaill jvaill commented Oct 28, 2016

Summary

When backspacing at the start of the first block using rich text utils, the block type should be cleared.

Example of me frantically trying to clear the first block type without this PR by pressing backspace at the beginning of the document:

clear-first-block-type

Followed by an example of me clearing the first block type with this PR:

clear-first-block-type-working

Test Plan

  • Pull master.
  • Open the rich text example.
  • Create a list.
  • Put your cursor at the first offset of the first block, backspace to reset the block type, notice that it doesn't work.
  • Pull this branch.
  • Open the rich text example.
  • Create a list.
  • Put your cursor at the first offset of the first block, backspace to reset the block type, rejoice in joy as the list item disappears.
  • Celebrate. 🎉

@facebook-github-bot
Copy link

Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours has expired.

Before we can review or merge your code, we need you to email cla@fb.com with your details so we can update your status.

@jvaill
Copy link
Contributor Author

jvaill commented Oct 28, 2016

^ Looks like Travis might need a retry?

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@jvaill jvaill closed this Nov 2, 2016
@jvaill jvaill deleted the backspace-start-reset-type branch November 2, 2016 21:39
@jvaill jvaill restored the backspace-start-reset-type branch November 2, 2016 21:40
@jvaill jvaill reopened this Nov 2, 2016
@flarnie flarnie self-requested a review October 14, 2017 23:31
Copy link
Contributor

@flarnie flarnie left a comment

Choose a reason for hiding this comment

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

I thiiiink this is ok. Could be seen as a breaking change, if the original behavior was intentional, but I don't think it was, so really this is fixing a bug.

Thanks!

thumb_up

@@ -59,7 +59,7 @@ describe('RichTextEditorUtil', () => {

// Remove the current text from the blockquote.
const resetBlockquote = DraftModifier.removeRange(
editorState.getCurrentContent(),
contentState,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice - thanks for fixing that.

@@ -82,6 +82,27 @@ describe('RichTextEditorUtil', () => {
expect(lastBlockNow.getText()).toBe('');
});

it('resets the current block type at the start of the first block', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for writing a test!

testing_i_love_testing

@flarnie
Copy link
Contributor

flarnie commented Oct 14, 2017

I'm going to try and resolve the conflicts, ensure CI passes, and merge this.

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@flarnie is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@flarnie has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@jvaill
Copy link
Contributor Author

jvaill commented Oct 20, 2017

Woot! Awesome to see this get merged. Thank you! @flarnie

@jvaill jvaill deleted the backspace-start-reset-type branch October 20, 2017 17:43
midas19910709 added a commit to midas19910709/draft-js that referenced this pull request Mar 30, 2022
Summary:
**Summary**

When backspacing at the start of the first block using rich text utils, the block type should be cleared.

Example of me frantically trying to clear the first block type **without** this PR by pressing backspace at the beginning of the document:

![clear-first-block-type](https://cloud.githubusercontent.com/assets/424704/19821170/d3296d9a-9d11-11e6-990d-e2277bbfb833.gif)

Followed by an example of me clearing the first block type **with** this PR:

![clear-first-block-type-working](https://cloud.githubusercontent.com/assets/424704/19821197/01b4826c-9d12-11e6-853b-32417ec93f10.gif)

**Test Plan**
- Pull master.
- Open the rich text example.
- Create a list.
- Put your cursor at the first offset of the first block, backspace to reset the block type, notice that it doesn't work.
- Pull this branch.
- Open the rich text example.
- Create a list.
- Put your cursor at the first offset of the first block, backspace to reset the block type, rejoice in joy as the list item disappears.
- Celebrate. 🎉
Closes facebookarchive/draft-js#748

Differential Revision: D6065808

fbshipit-source-id: d4b9028e255be1bdf405cf228cfd16c877872c95
alicayan008 pushed a commit to alicayan008/draft-js that referenced this pull request Jul 4, 2023
Summary:
**Summary**

When backspacing at the start of the first block using rich text utils, the block type should be cleared.

Example of me frantically trying to clear the first block type **without** this PR by pressing backspace at the beginning of the document:

![clear-first-block-type](https://cloud.githubusercontent.com/assets/424704/19821170/d3296d9a-9d11-11e6-990d-e2277bbfb833.gif)

Followed by an example of me clearing the first block type **with** this PR:

![clear-first-block-type-working](https://cloud.githubusercontent.com/assets/424704/19821197/01b4826c-9d12-11e6-853b-32417ec93f10.gif)

**Test Plan**
- Pull master.
- Open the rich text example.
- Create a list.
- Put your cursor at the first offset of the first block, backspace to reset the block type, notice that it doesn't work.
- Pull this branch.
- Open the rich text example.
- Create a list.
- Put your cursor at the first offset of the first block, backspace to reset the block type, rejoice in joy as the list item disappears.
- Celebrate. 🎉
Closes facebookarchive/draft-js#748

Differential Revision: D6065808

fbshipit-source-id: d4b9028e255be1bdf405cf228cfd16c877872c95
aforismesen added a commit to aforismesen/draft-js that referenced this pull request Jul 12, 2024
Summary:
**Summary**

When backspacing at the start of the first block using rich text utils, the block type should be cleared.

Example of me frantically trying to clear the first block type **without** this PR by pressing backspace at the beginning of the document:

![clear-first-block-type](https://cloud.githubusercontent.com/assets/424704/19821170/d3296d9a-9d11-11e6-990d-e2277bbfb833.gif)

Followed by an example of me clearing the first block type **with** this PR:

![clear-first-block-type-working](https://cloud.githubusercontent.com/assets/424704/19821197/01b4826c-9d12-11e6-853b-32417ec93f10.gif)

**Test Plan**
- Pull master.
- Open the rich text example.
- Create a list.
- Put your cursor at the first offset of the first block, backspace to reset the block type, notice that it doesn't work.
- Pull this branch.
- Open the rich text example.
- Create a list.
- Put your cursor at the first offset of the first block, backspace to reset the block type, rejoice in joy as the list item disappears.
- Celebrate. 🎉
Closes facebookarchive/draft-js#748

Differential Revision: D6065808

fbshipit-source-id: d4b9028e255be1bdf405cf228cfd16c877872c95
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants