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

[RNMobile] Make placeholder text working on RichText #13699

Merged
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
8 changes: 7 additions & 1 deletion packages/editor/src/components/rich-text/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,12 @@ export class RichText extends Component {
} ) );

// Save back to HTML from React tree
const html = '<' + tagName + '>' + value + '</' + tagName + '>';
let html = '<' + tagName + '>' + value + '</' + tagName + '>';
// We need to check if the value is undefined or empty, and then assign it properly otherwise the placeholder is not visible
if ( value === undefined || value === '' ) {
html = '';
this.lastEventCount = undefined; // force a refresh on the native side
}

return (
<View>
Expand All @@ -373,6 +378,7 @@ export class RichText extends Component {
}
}
text={ { text: html, eventCount: this.lastEventCount } }
placeholder={ this.props.placeholder }
onChange={ this.onChange }
onFocus={ this.props.onFocus }
onBlur={ this.props.onBlur }
Expand Down