Skip to content

Commit

Permalink
Handle the case when the split occurs at the trailing or leading edge…
Browse files Browse the repository at this point in the history
… of the field. (#10737)
  • Loading branch information
daniloercoli authored and diegoreymendez committed Oct 18, 2018
1 parent c3501c7 commit 1e82348
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Component, RawHTML } from '@wordpress/element';
import { withInstanceId, compose } from '@wordpress/compose';
import { Toolbar } from '@wordpress/components';
import {
isEmpty,
create,
split,
toHTMLString,
Expand Down Expand Up @@ -87,10 +88,18 @@ export class RichText extends Component {
} );

// TODO : Fix the index position in AztecNative for Android
let [ before, after ] = split( { start: start - 6, end: end - 6, ...record } );

// TODO : Handle here the cases when the split happens at the trailing or leading edge...
// See the web version for reference.
let [ before, after ] = split( { start, end, ...record } );

// In case split occurs at the trailing or leading edge of the field,
// assume that the before/after values respectively reflect the current
// value. This also provides an opportunity for the parent component to
// determine whether the before/after value has changed using a trivial
// strict equality operation.
if ( isEmpty( after ) ) {
before = record;
} else if ( isEmpty( before ) ) {
after = record;
}

if ( before ) {
before = this.valueToFormat( before );
Expand Down

0 comments on commit 1e82348

Please sign in to comment.