question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Placeholder not rendering

See original GitHub issue

What’s the bug you are facing?

When the editor is empty, either initially, or after deletion, no placeholder is displayed to the user.

A paragraph node is added with the appropriate classes, and a data-placeholder as set by my configuration, however, there is no displayed placeholder for the user. The Paragraph tag just contains an empty <br/>

image

How can we reproduce the bug on our side?

Set up basic editor, use @tiptap/extension-placeholder as per docs

Can you provide a CodeSandbox?

No response

What did you expect to happen?

The placeholder text gets displayed when there is no content.

Anything to add? (optional)

No response

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
KarolMilewskicommented, Mar 29, 2022

add some CSS to your component

/* Placeholder (at the top) */
.ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  float: left;
  color: #adb5bd;
  pointer-events: none;
  height: 0;
}

/* Placeholder (on every new line) */
/*.ProseMirror p.is-empty::before {
  content: attr(data-placeholder);
  float: left;
  color: #adb5bd;
  pointer-events: none;
  height: 0;
}*/
6reactions
larsdjursnercommented, May 18, 2022

Any guidance on how to style the placeholder with Tailwind?

I’m using this:

Placeholder.configure({
  placeholder,
  emptyNodeClass:
    'first:before:text-gray-400 first:before:float-left first:before:content-[attr(data-placeholder)] first:before:pointer-events-none',
}),

The placeholder works but the cursor isn’t placed at the beginning of the placeholder text: Screenshot 2022-05-02 at 17 40 42

Did you manage to find a solution? Adding “first:before:h-0” to emptyNodeClass worked for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

input placeholder is not showing - Stack Overflow
Thus, placeholder will only be set only on the blur event. To explicitly set the placeholder use the placeholder property of input tag:...
Read more >
placeholder-shown - CSS-Tricks
:placeholder-shown , being a pseudo-class, has to select an existing element. It selects the input whenever you're in the placeholder-showing ...
Read more >
I'm getting this warning. The xxx placeholder was not rendered ...
"The xxx placeholder was not rendered in the item rendering context Possible causes: Rendering markup was taken from HTML cache, thus no rendering...
Read more >
:placeholder-shown - CSS: Cascading Style Sheets | MDN
The :placeholder-shown CSS pseudo-class represents any <input> or <textarea> element that is currently displaying placeholder text.
Read more >
Dynamic Placeholders Not Displaying Allowed Renderings
The solution is to change the load order in the Modules layer such that the Coveo configuration file is processed ahead of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found