Skip to content

Fix error when pasting image in caption#4603

Merged
ellatrix merged 4 commits intomasterfrom
fix/error-caption-paste-image
Feb 8, 2018
Merged

Fix error when pasting image in caption#4603
ellatrix merged 4 commits intomasterfrom
fix/error-caption-paste-image

Conversation

@ellatrix
Copy link
Copy Markdown
Member

Description

Caused by #4298. An error occurs if you paste a single image (right click, copy image) inside an editable field that does not support the splitting of content, e.g. an image caption.

How Has This Been Tested?

See above.

// Necessary to allow the paste bin to be removed without errors.
setTimeout( () => this.props.onReplace( content ) );
} else {
} else if ( this.props.onSplit ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this check be consolidated in splitContent instead, so in case we add another call to the function we don't need to similarly guard?

} else if ( this.props.onSplit ) {
// Necessary to get the right range.
// Also done in the TinyMCE paste plugin.
setTimeout( () => this.splitContent( content ) );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We're not clearing this timeout if the component unmounts.

@@ -303,7 +303,7 @@ export default class Editable extends Component {
if ( isEmpty && this.props.onReplace ) {
// Necessary to allow the paste bin to be removed without errors.
setTimeout( () => this.props.onReplace( content ) );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We're not clearing this timeout if the component unmounts.

@ellatrix ellatrix force-pushed the fix/error-caption-paste-image branch from 121a5b1 to 4b9e8a2 Compare January 30, 2018 21:07
@ellatrix
Copy link
Copy Markdown
Member Author

@aduth Fixed the timeouts... What do you think of this solution?

@ellatrix ellatrix requested a review from aduth January 30, 2018 21:08
@ellatrix ellatrix force-pushed the fix/error-caption-paste-image branch from 4b9e8a2 to 88ac125 Compare February 1, 2018 17:01
@ellatrix
Copy link
Copy Markdown
Member Author

ellatrix commented Feb 1, 2018

Rebased after Editable rename.

@ellatrix
Copy link
Copy Markdown
Member Author

ellatrix commented Feb 7, 2018

Blocked by #4839 if we really want to fix the timeouts here too.

@ellatrix ellatrix force-pushed the fix/error-caption-paste-image branch from 88ac125 to 1e74241 Compare February 8, 2018 13:42
@ellatrix
Copy link
Copy Markdown
Member Author

ellatrix commented Feb 8, 2018

I removed the setTimout changes here. It's being worked on by @mcsf in #4839. Since this PR does not touch that further and fixes a small straightforward error, I'm going to merge.

@ellatrix
Copy link
Copy Markdown
Member Author

ellatrix commented Feb 8, 2018

With the setTimout changes I mean 7f76335.

@ellatrix ellatrix merged commit f99b3a7 into master Feb 8, 2018
@ellatrix ellatrix deleted the fix/error-caption-paste-image branch February 8, 2018 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants