mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 03:36:07 +03:00
workaround for placeholder being shown when empty text but block. Fixes vector-im/riot-web#7042
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
1b467f6ca8
commit
720a728278
1 changed files with 10 additions and 2 deletions
|
@ -1533,6 +1533,14 @@ export default class MessageComposerInput extends React.Component {
|
|||
mx_MessageComposer_input_error: this.state.someCompletions === false,
|
||||
});
|
||||
|
||||
const isEmpty = this.state.editorState.document.isEmpty;
|
||||
|
||||
let {placeholder} = this.props;
|
||||
// XXX: workaround for placeholder being shown when there is a formatting block e.g blockquote but no text
|
||||
if (isEmpty && this.state.editorState.startBlock.type !== DEFAULT_NODE) {
|
||||
placeholder = undefined;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mx_MessageComposer_input_wrapper" onClick={this.focusComposer}>
|
||||
<div className="mx_MessageComposer_autocomplete_wrapper">
|
||||
|
@ -1554,7 +1562,7 @@ export default class MessageComposerInput extends React.Component {
|
|||
<Editor ref="editor"
|
||||
dir="auto"
|
||||
className="mx_MessageComposer_editor"
|
||||
placeholder={this.props.placeholder}
|
||||
placeholder={placeholder}
|
||||
value={this.state.editorState}
|
||||
onChange={this.onChange}
|
||||
onKeyDown={this.onKeyDown}
|
||||
|
@ -1564,7 +1572,7 @@ export default class MessageComposerInput extends React.Component {
|
|||
renderNode={this.renderNode}
|
||||
renderMark={this.renderMark}
|
||||
// disable spell check for the placeholder because browsers don't like "unencrypted"
|
||||
spellCheck={!this.state.editorState.document.isEmpty}
|
||||
spellCheck={!isEmpty}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue