React-draft-wysiwyg: Placeholder still shows when creating list

Created on 10 Aug 2017  路  10Comments  路  Source: jpuri/react-draft-wysiwyg

If a ordered or unordered list is started before typing any text the placeholder text still displays which looks weird as the bullet point or number are rendered on top.

Most helpful comment

Hi there!
That's the problem of js-draft. Link to issue
If you inspect the code you can check the placeholder component.
image
The placeholder is still here but was hidden by css (link to docs)
image

`

const {editorState} = this.state;

// If the user changes block type before entering any text, we can
// either style the placeholder or hide it. Let's just hide it now.
let className = 'RichEditor-editor';
var contentState = editorState.getCurrentContent();
if (!contentState.hasText()) {
  if (contentState.getBlockMap().first().getType() !== 'unstyled') {
    className += ' RichEditor-hidePlaceholder';
  }
}

return (
  <div className="RichEditor-root">
    <div className={className}>
      <Editor  placeholder="Tell a story..."  />
    </div>
  </div>
);

`

All 10 comments

@ljowen : thanks for reporting this issue. I will soon check.

@ljowen : I could not replicate this:
screen shot 2017-08-12 at 10 53 01 pm

@jpuri : see attached, showing the number before anything has been typed.
screenshot from 2017-08-14 10-45-42

@ljowen : do you also see some errors in console ?

Just two failed GET's:
GET https://jpuri.github.io/react-draft-wysiwyg/static/bundle.js jpuri.github.io/:1
GET https://jpuri.github.io/react-draft-wysiwyg/static/main.css jpuri.github.io/:1

This is Chrome and Firefox on Ubuntu btw

@jpuri Hi! I'm facing this issue too. Do you have any solution for this? Thanks.

Hi there!
That's the problem of js-draft. Link to issue
If you inspect the code you can check the placeholder component.
image
The placeholder is still here but was hidden by css (link to docs)
image

`

const {editorState} = this.state;

// If the user changes block type before entering any text, we can
// either style the placeholder or hide it. Let's just hide it now.
let className = 'RichEditor-editor';
var contentState = editorState.getCurrentContent();
if (!contentState.hasText()) {
  if (contentState.getBlockMap().first().getType() !== 'unstyled') {
    className += ' RichEditor-hidePlaceholder';
  }
}

return (
  <div className="RichEditor-root">
    <div className={className}>
      <Editor  placeholder="Tell a story..."  />
    </div>
  </div>
);

`

@Frozzy6 : good finding 馃憤 I will add this to the editor also.

Hello,
I'm having the same issue, have you guys solved the problem? it happens even in you live demo here: https://jpuri.github.io/react-draft-wysiwyg/#/

Thanks! and thank you for the work you are doing

@MeSanti, I described the solution in my previous message.

in a nutshell use css to hide the placeholder

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gyarasu picture gyarasu  路  4Comments

jpuri picture jpuri  路  4Comments

Satherial picture Satherial  路  4Comments

volkandkaya picture volkandkaya  路  3Comments

FriOne picture FriOne  路  3Comments