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

Make sure that HTML that is sent is correctly updated. #17710

Merged
merged 3 commits into from
Oct 2, 2019
Merged
Changes from all 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
18 changes: 12 additions & 6 deletions packages/rich-text/src/component/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ export class RichText extends Component {
/**
* Handles a paste event from the native Aztec Wrapper.
*
* @param {PasteEvent} event The paste event which wraps `nativeEvent`.
* @param {Object} event The paste event which wraps `nativeEvent`.
*/
onPaste( event ) {
const {
Expand Down Expand Up @@ -753,13 +753,19 @@ export class RichText extends Component {

getHtmlToRender( record, tagName ) {
// Save back to HTML from React tree
const value = this.valueToFormat( record );
let value = this.valueToFormat( record );

if ( value === undefined || value === '' ) {
if ( value === undefined ) {
this.lastEventCount = undefined; // force a refresh on the native side
return '';
} else if ( tagName ) {
return `<${ tagName }>${ value }</${ tagName }>`;
value = '';
}
// On android if content is empty we need to send no content or else the placeholder with not show.
if ( ! this.iOS && value === '' ) {
return value;
}

if ( tagName ) {
value = `<${ tagName }>${ value }</${ tagName }>`;
}
return value;
}
Expand Down