Skip to content

Commit

Permalink
Make sure end is always greater than start for the text selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Tug committed Dec 17, 2018
1 parent 971b18a commit 1daafef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ export class RichText extends Component {
}

onSelectionChange( start, end ) {
this.setState( { start, end } );
// `end` can be less than `start` on iOS
// Let's fix that here so `rich-text/slice` can work properly
const realStart = Math.min( start, end );
const realEnd = Math.max( start, end );
this.setState( { start: realStart, end: realEnd } );
}

isEmpty() {
Expand Down

0 comments on commit 1daafef

Please sign in to comment.