Draft-js: Editor is placed under the placeholder

Created on 22 Jul 2016  路  2Comments  路  Source: facebook/draft-js

When specifying placeholder attribute to the Draft.Editor component, the placeholder element is rendered with position: relative (as far as I can see) so it comes above the editor itself.

gifrecord_2016-07-22_164239

Most helpful comment

My Editor component uses custom block-styling which apparently does not merge the original styles with mine, but completely overrides them. So what I was missing was adding CSS rules for the placeholder itself:

.public/DraftEditorPlaceholder/root {
    @extend .RichEditor/block;
    color: var(palette-grey-500);
    position: absolute;
    z-index: 0;
}

.public/DraftEditorPlaceholder/hasFocus {
    color: var(palette-grey-700);
}

.DraftEditorPlaceholder/hidden {
    display: none;
}

P.S. I leave this here for others who might miss the same thing as I did!

All 2 comments

My Editor component uses custom block-styling which apparently does not merge the original styles with mine, but completely overrides them. So what I was missing was adding CSS rules for the placeholder itself:

.public/DraftEditorPlaceholder/root {
    @extend .RichEditor/block;
    color: var(palette-grey-500);
    position: absolute;
    z-index: 0;
}

.public/DraftEditorPlaceholder/hasFocus {
    color: var(palette-grey-700);
}

.DraftEditorPlaceholder/hidden {
    display: none;
}

P.S. I leave this here for others who might miss the same thing as I did!

I had the same problem. Thank you!

For Create React App users, you can import Draft's CSS: import "draft-js/dist/Draft.css";

Was this page helpful?
0 / 5 - 0 ratings