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

[Mobile] Fix caret position after inline paste - after selection refactor #15701

Merged
merged 5 commits into from
May 30, 2019
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions packages/block-editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,14 @@ export class RichText extends Component {

if ( typeof pastedContent === 'string' ) {
const recordToInsert = create( { html: pastedContent } );
const insertedContent = insert( currentRecord, recordToInsert );
const newContent = this.valueToFormat( insertedContent );
const resultingRecord = insert( currentRecord, recordToInsert );
const resultingContent = this.valueToFormat( resultingRecord );

this.lastEventCount = undefined;
this.value = newContent;
this.value = resultingContent;

// explicitly set selection after inline paste
this.forceSelectionUpdate( insertedContent.start, insertedContent.end );
this.onSelectionChange( resultingRecord.start, resultingRecord.end );
mkevins marked this conversation as resolved.
Show resolved Hide resolved

this.props.onChange( this.value );
} else if ( onSplit ) {
Expand Down Expand Up @@ -673,15 +673,6 @@ export class RichText extends Component {
return value;
}

forceSelectionUpdate( start, end ) {
if ( ! this.needsSelectionUpdate ) {
this.needsSelectionUpdate = true;
this.selectionStart = start;
this.selectionEnd = end;
this.forceUpdate();
}
}

shouldComponentUpdate( nextProps ) {
if ( nextProps.tagName !== this.props.tagName ) {
this.lastEventCount = undefined;
Expand Down