Skip to content

Commit

Permalink
[RNMobile] iOS Image block caption multiline fix (#16071)
Browse files Browse the repository at this point in the history
* Add unit test to cover multiline rich-text onEnter appends br tag

* Fix iOS issue where pressing Enter on image caption won't create a new line
  • Loading branch information
etoledom authored Jun 10, 2019
1 parent a5a3c08 commit 4d08cc5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export class RichText extends Component {
const insertedLineSeparator = { ...insertLineSeparator( currentRecord ) };
this.onFormatChange( insertedLineSeparator );
}
} else if ( event.shiftKey || ! this.onSplit ) {
} else if ( event.shiftKey || ! onSplit ) {
this.needsSelectionUpdate = true;
const insertedLineBreak = { ...insert( currentRecord, '\n' ) };
this.onFormatChange( insertedLineBreak );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* External dependencies
*/
import { shallow } from 'enzyme';

/**
* Internal dependencies
*/
Expand All @@ -24,4 +29,28 @@ describe( 'RichText Native', () => {
expect( richText.willTrimSpaces( html ) ).toBe( false );
} );
} );

describe( 'Adds new line on Enter', () => {
let newValue;
const wrapper = shallow( <RichText
rootTagsToEliminate={ [ 'p' ] }
value={ "" }
onChange={ ( value ) => {
newValue = value
} }
formatTypes={ [] }
onSelectionChange={ jest.fn() }
/> );

const event = {
nativeEvent: {
eventCount: 0,
}
};
wrapper.instance().onEnter(event);

it( ' Adds <br> tag to content after pressing Enter key', () => {
expect( newValue ).toEqual( "<br>" );
});
} );
} );

0 comments on commit 4d08cc5

Please sign in to comment.