From d692f7f14fa9bdaea58029d4636353837dc72ae4 Mon Sep 17 00:00:00 2001 From: iseulde Date: Sun, 9 Dec 2018 14:46:32 -0600 Subject: [PATCH] RichText: Ensure instance is selected before setting back selection --- packages/editor/src/components/rich-text/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/editor/src/components/rich-text/index.js b/packages/editor/src/components/rich-text/index.js index de0e7dd5aa3633..0731916d6a1a73 100644 --- a/packages/editor/src/components/rich-text/index.js +++ b/packages/editor/src/components/rich-text/index.js @@ -688,9 +688,12 @@ export class RichText extends Component { if ( shouldReapply ) { const record = this.formatToValue( value ); - // Maintain the previous selection: - record.start = this.state.start; - record.end = this.state.end; + // Maintain the previous selection if the instance is currently + // selected. + if ( isSelected ) { + record.start = this.state.start; + record.end = this.state.end; + } this.applyRecord( record ); }