Click on placeholder rather next to it
Hello everyone,
I have been trying to modify the way the placeholder works in my project.
Currently, if I click next to the placeholder, it will place the caret where I want it to be and the text will start typing as expected. However if I click on the placeholder itself, it will select it as a normal text. Instead, I would like the caret to appear when i click on the placeholder.
Maybe I didn't search hard enough but i haven't found any information on that topic so far.
Thank you
Hi @vincentdegheyndt, have you seen #403? See also the note about placeholder styling on https://draftjs.org/docs/api-reference-editor/.
Thnaks @thibaudcolas,
Yes I have seen that issue and already used a custom css file to prevent that behaviour of the caret as they explain.
However I don't know of any css property that would make the placeholder text "unselectable". If there is then a custom css file should do the trick, I reckon.
EDIT : there's "user-select:none". It did make the placeholder unselectable as expected but I still have to click next to the placeholder for the caret to appear.
Oh that’s strange – Draft.css is meant to come with the styles that do this, I think. Here are the relevant styles:
.DraftEditor-editorContainer {
background-color: rgba(255, 255, 255, 0);
border-left: .1px solid transparent;
position: relative;
z-index: 1;
}
.public-DraftEditorPlaceholder-root {
color: #9197a3;
position: absolute;
z-index: 1;
}
At least in my editor this seems to be enough for the placeholder to not be clickable, since the "editor container" is in front of it.
This worked !!!
Thank you very much for your help;